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如何容器迁移到另外一台服务器上运行 #221

Open
felix-cao opened this issue May 26, 2024 · 0 comments
Open

Docker如何容器迁移到另外一台服务器上运行 #221

felix-cao opened this issue May 26, 2024 · 0 comments

Comments

@felix-cao
Copy link
Owner

felix-cao commented May 26, 2024

以下四步为 Docker 把容器打包成镜像并迁移到另外一台服务器上运行,

1. 将容器 commit 为镜像

使用 docker commit 命令可以将现有的容器状态保存为新的镜像。这个过程类似于创建一个镜像的快照。

假设您的容器名称是 your-container-name,您想要创建的新镜像名为 your-new-image-name。命令格式如下:

docker commit your-container-name your-new-image-name

2. 将镜像保存为本地文件

docker save -o your-image-file.tar your-new-image-name

3. 将本地镜像文件传输至远程服务器

4. 在服务器上执行 docker load

docker load -i your-image-file.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