“Export/import导出和导入docker容器”的版本间的差异
跳到导航
跳到搜索
(创建页面,内容为“==导出== docker export docker4wiki_mediawiki_1 >docker4wiki_mediawiki_1.tar docker export docker4wiki_database_1 >docker4wiki_database_1.tar ==导入==…”) |
(→导入) |
||
(未显示同一用户的7个中间版本) | |||
第5行: | 第5行: | ||
==导入== | ==导入== | ||
+ | <pre> | ||
+ | Import to docker via pipe and STDIN | ||
+ | cat ./你的导出.tar | sudo docker import - 新的名字:1.0 | ||
+ | Import with a commit message | ||
+ | $ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new | ||
+ | #我的命令 | ||
+ | cat docker4wiki_database_1.tar | docker import --message "dbwiki" - imported:docker4wiki_database_1 | ||
+ | sha256:448b3bb2fd26b1d107dfd46df75bfdd12b0e0f11e4eaef8c9c2d9d4adec289af | ||
+ | |||
+ | sudo docker images可以看到刚才导入的新镜像 | ||
+ | REPOSITORY TAG IMAGE ID CREATED SIZE | ||
+ | imported docker4wiki_database_1 448b3bb2fd26 25 seconds ago 350MB | ||
+ | |||
+ | |||
+ | 根据自己的需要开启容器 | ||
+ | |||
+ | docker run -dit -v /dep:/dep -p 80:80 -p 7000-7001:7000-7001 dockertest:1.0 /bin/bash | ||
+ | |||
+ | -v 是docker目录挂载,冒号左边是本地目录,右边是docker内目录 | ||
+ | -p 是docker端口映射,冒号左边是本地端口,右边是docker内端口 | ||
+ | |||
+ | |||
+ | |||
+ | #我的命令 | ||
+ | 具体的command需要在导出容器的时候通过docker ps查看到。 或者直接加 /bin/bash 应该也行 | ||
+ | ocker ps | ||
+ | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | ||
+ | mariadb "docker-entrypoint.s…" 2 weeks ago Up 13 days 0.0.0.0:3306->3306/tcp docker4wiki_database_1 | ||
+ | |||
+ | |||
+ | docker run --name mymariadb -p 3306:3306 --restart always -v /data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=2240881 -d 448b3bb2fd26 docker-entrypoint.sh | ||
+ | 3ff1f5f0cfe027c88fe3f736181069e2bf90097ab3a47cc997212db5f73bb2cc | ||
+ | |||
+ | |||
+ | |||
+ | </pre> | ||
+ | |||
+ | https://docs.docker.com/engine/reference/commandline/export/ | ||
+ | |||
+ | https://docs.docker.com/engine/reference/commandline/import/ | ||
+ | |||
+ | https://blog.csdn.net/weixin_42003671/article/details/86614577 | ||
=troubleshooting= | =troubleshooting= | ||
第15行: | 第57行: | ||
[[Linux添加swap交换分区(虚拟内存)]] | [[Linux添加swap交换分区(虚拟内存)]] | ||
+ | |||
+ | 导入的错误 | ||
+ | 注意:运行导入的镜像的时候必须带command,否则启动报如下错误 | ||
+ | |||
+ | FATA[0000] Error response from daemon: No command specified | ||
+ | |||
+ | 具体的command需要在导出容器的时候通过docker ps查看到。 | ||
+ | |||
+ | =see also= | ||
+ | [https://www.cnblogs.com/wish123/p/6573899.html docker export import后,导入镜像,启动时的错误,Error response from daemon: No command specified] | ||
[[category:Container]] | [[category:Container]] |
2019年10月31日 (四) 01:30的最新版本
导出
docker export docker4wiki_mediawiki_1 >docker4wiki_mediawiki_1.tar
docker export docker4wiki_database_1 >docker4wiki_database_1.tar
导入
Import to docker via pipe and STDIN cat ./你的导出.tar | sudo docker import - 新的名字:1.0 Import with a commit message $ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new #我的命令 cat docker4wiki_database_1.tar | docker import --message "dbwiki" - imported:docker4wiki_database_1 sha256:448b3bb2fd26b1d107dfd46df75bfdd12b0e0f11e4eaef8c9c2d9d4adec289af sudo docker images可以看到刚才导入的新镜像 REPOSITORY TAG IMAGE ID CREATED SIZE imported docker4wiki_database_1 448b3bb2fd26 25 seconds ago 350MB 根据自己的需要开启容器 docker run -dit -v /dep:/dep -p 80:80 -p 7000-7001:7000-7001 dockertest:1.0 /bin/bash -v 是docker目录挂载,冒号左边是本地目录,右边是docker内目录 -p 是docker端口映射,冒号左边是本地端口,右边是docker内端口 #我的命令 具体的command需要在导出容器的时候通过docker ps查看到。 或者直接加 /bin/bash 应该也行 ocker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES mariadb "docker-entrypoint.s…" 2 weeks ago Up 13 days 0.0.0.0:3306->3306/tcp docker4wiki_database_1 docker run --name mymariadb -p 3306:3306 --restart always -v /data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=2240881 -d 448b3bb2fd26 docker-entrypoint.sh 3ff1f5f0cfe027c88fe3f736181069e2bf90097ab3a47cc997212db5f73bb2cc
https://docs.docker.com/engine/reference/commandline/export/
https://docs.docker.com/engine/reference/commandline/import/
https://blog.csdn.net/weixin_42003671/article/details/86614577
troubleshooting
Question docker export : "fatal error: runtime: out of memory
Solution Linux添加swap交换分区(虚拟内存)
导入的错误
注意:运行导入的镜像的时候必须带command,否则启动报如下错误
FATA[0000] Error response from daemon: No command specified
具体的command需要在导出容器的时候通过docker ps查看到。
see also
docker export import后,导入镜像,启动时的错误,Error response from daemon: No command specified