Docker导出本地镜像和导入镜像

查看本机镜像

# docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
webconsole          latest              aba01f181a4a        5 seconds ago       593 MB

将镜像保存为本地文件

# docker save aba01f181a4a > /opt/webconsole.tar

aba01f181a4a 为 IMAGE ID,将导出的镜像上传到另一台机器,然后执行导入操作

# docker load < webconsole.tar

040fd7841192: Loading layer [==================================================>] 4.234 MB/4.234 MB
0f20ab684106: Loading layer [==================================================>]   959 kB/959 kB
e8984b733970: Loading layer [==================================================>] 3.072 kB/3.072 kB
61d11dce11a7: Loading layer [==================================================>] 258.1 MB/258.1 MB
f11c0d75456c: Loading layer [==================================================>]  2.56 kB/2.56 kB
46ba3a5cbbcc: Loading layer [==================================================>] 5.632 kB/5.632 kB
185300076fe6: Loading layer [==================================================>] 324.8 MB/324.8 MB
ab113f5d3101: Loading layer [==================================================>] 13.96 MB/13.96 MB
adda2c8b8266: Loading layer [==================================================>] 2.048 kB/2.048 kB
Loaded image ID: sha256:aba01f181a4aa9aa92c27232fd22a1852c1d48f00db85f57d4d3896cd08b7851

查看镜像列表

# docker images

REPOSITORY                                                                    TAG                 IMAGE ID            CREATED             SIZE
<none>                                                                        <none>              aba01f181a4a        20 minutes ago      593 MB

发现加载进来的镜像名称、标签均为none,打上tag

# docker tag aba01f181a4a webconsole:latest

验证镜像是否能够成功运行

# docker run -itd webconsole:latest
微信公众号
关注36nu微信公众账号
获取最新编程知识及经验