不存在时会出现错误信息: Unable to find image ‘ubuntu:15.10’ locally
之后便会从镜像仓库下载公共镜像
打印 hello world
M1-Mac 可能会出现如下警告:WARNING: The requested image’s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
解决方法:docker run –platform linux/amd64 ubuntu:15.10 /bin/echo ‘hello world’
REPOSITORY TAG IMAGE ID CREATED SIZE react-demo-image latest 35c499bddac6 3 minutes ago 1.22GB node-test latest 028a51c6e54d 8 months ago 945MB nginx latest f1325989da19 8 months ago 134MB
运行容器
1
docker run -p 8081:3000 -d --name react-demo-server react-demo-image
查看容器
1 2
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f71ef1480035 react-demo-image "docker-entrypoint.s…" 4 seconds ago Up 3 seconds 0.0.0.0:8081->3000/tcp react-demo-server
(node:27) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option. (Use `node --trace-deprecation ...` to show where the warning was created) (node:27) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option. Starting the development server...
Compiled successfully!
You can now view react-demo in the browser.
Local: http://localhost:3000 On Your Network: http://172.17.0.2:3000
Note that the development build is not optimized. To create a production build, use npm run build.