[root@docker-test home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8634c76e01d1 nginx "/docker-entrypoint.…" 2 hours ago Up 2 hours 0.0.0.0:8080->80/tcp, :::8080->80/tcp nginx
[root@docker-test home]# docker export 8634c76e01d1 > nginx.tar
[root@docker-test home]# cat nginx.tar | docker import - nginx:test
sha256:b47c6c6bddaf1433bba6ed64dc2daa4bafe569919556834c1a0b884bab228dc4
[root@docker-test home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx test b47c6c6bddaf 5 seconds ago 140MB
[root@docker-test home]# docker run --name nginx-test -p 8081:80 -d nginx:test
docker: Error response from daemon: no command specified.
See 'docker run --help'.
##被docker export出来的镜像在启动的时候需要指定command,例如我启动上述nginx容器,需要指定Command
##Command可以通过下面命令查询到:
[root@docker-test home]# docker ps -a --no-trunc
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8634c76e01d18cf913ebaee30a354b6c588b1780102de810c82c065501434b00 nginx "/docker-entrypoint.sh nginx -g 'daemon off;'" 3 hours ago Up 2 hours 0.0.0.0:8080->80/tcp, :::8080->80/tcp nginx
[root@docker-test home]# docker run --name nginx-test -d -p 8081:80 nginx:test /docker-entrypoint.sh nginx -g 'daemon off;'
d31501aa46ebc5c0fd9119a8895d537ef0c3d813d1e2783ca2b02642cdd86fb7
[root@docker-test home]# docker ps -a
docker export的镜像启动报错Error response from daemon: no command specified.
于 2024-01-22 18:00:55 首次发布
本文讲述了如何使用`dockerexport`导出并导入Docker镜像,以及在启动时指定`command`的必要性。示例中作者展示了如何正确运行带有自定义启动指令的`nginx`容器。
摘要由CSDN通过智能技术生成