Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker中镜像导入导出 #139

Open
wuxianqiang opened this issue Apr 20, 2019 · 0 comments
Open

docker中镜像导入导出 #139

wuxianqiang opened this issue Apr 20, 2019 · 0 comments

Comments

@wuxianqiang
Copy link
Owner

export/import

centos镜像为例

  1. 根据镜像构建一个容器

docker run centos

  1. 查看刚才生成的容器ID191e8ede2979

docker container ps -a

  1. 导出容器到文件centos.tar

docker export -o centos.tar 191e8ede2979

  1. 删除本地镜像(删除镜像之前要先删除容器)

docker container rm 191e8ede2979
docker image rmi centos

  1. 把文件centos.tar导入为镜像

docker import centos.tar

需要指定名称和标签(默认没有)
没有名称和标签的镜像可以通过docker image prune删除

save/load

centos镜像为例

  1. 把镜像导出为文件centos.tar

docker save centos.tar centos

  1. 删除本地镜像

docker image rmi centos

  1. 把文件导入为镜像

docker load -i centos.tar

不能修改名称和标签(默认自带之前的)

区别:一个操作的是容器,一个操作的是镜像

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant