我是靠谱客的博主 无私御姐,最近开发中收集的这篇文章主要介绍Docker镜像的打包部署Docker镜像的打包部署,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Docker镜像的打包部署

启动个docker

C:Usersdocker>docker images
REPOSITORY
TAG
IMAGE ID
CREATED
SIZE
centos
latest
e934aafc2206
2 months ago
199MB
C:Usersdocker>docker run -it centos /bin/bash
[root@ebaef8570358 /]# ls
anaconda-post.log
bin
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var

在这个docker上做些修改

[root@ebaef8570358 /]# echo 'hello word' >/tmp/hello_word.txt
[root@ebaef8570358 /]# ls /tmp
hello_word.txt
ks-script-hE5IPf
yum.log

查看修改的内容

[root@9e567dad37a5 /]# exit
exit
C:Usersdocker>docker diff 9e56
C /root
A /root/.bash_history
C /tmp
A /tmp/hello_word.txt

C: Change
A: Add
D: Delete

提交修改到镜像

C:Usersdocker>docker commit 9e567 centos:update
sha256:43442c42ff38a02f2da0cc1dc5a6d6dafdd5e3e38c275ad26e341ef646779c22

看一下镜像有没有保存好

C:Usersdocker>docker images
REPOSITORY
TAG
IMAGE ID
CREATED
SIZE
centos
update
43442c42ff38
32 seconds ago
199MB
centos
latest
e934aafc2206
2 months ago
199MB

导出和导入

C:Usersdocker>docker export 9e567 >centos_v1.tar
C:Usersdocker>dir centos_v1.tar
centos_v1.tar
C:Usersdocker>docker import - centos_v1 <centos_v1.tar
sha256:b5ab33184f364c79e78a9e8ca699b6171ce958cdff6b43c904017fac9f2ba6ca
C:Usersgchen1>docker images
REPOSITORY
TAG
IMAGE ID
CREATED
SIZE
centos_v1
latest
b5ab33184f36
About a minute ago
199MB
centos
update
43442c42ff38
7 minutes ago
199MB
centos
latest
e934aafc2206
2 months ago
199MB

镜像的备份和恢复

C:Usersdocker>docker save -o centos_backup.tar centos:update
C:Usersdocker>dir centos_bakup.tar
centos_backup.tar
C:Usersdocker>docker load <centos_backup.tar
C:Usersdocker>docker rmi centos:update
Untagged: centos:update
Deleted: sha256:43442c42ff38a02f2da0cc1dc5a6d6dafdd5e3e38c275ad26e341ef646779c22
Deleted: sha256:6fe11269af1f253b2d234c0c81833744818c7ac5eb6e4ec343ab9628103333f4
C:Usersdocker>docker load <centos_backup.tar
7948c8051341: Loading layer [==================================================>]
4.096kB/4.096kB
Loaded image: centos:update
C:Usersdocker>docker images
REPOSITORY
TAG
IMAGE ID
CREATED
SIZE
centos_v1
latest
b5ab33184f36
9 minutes ago
199MB
centos
update
43442c42ff38
16 minutes ago
199MB
centos
latest
e934aafc2206
2 months ago
199MB

最后

以上就是无私御姐为你收集整理的Docker镜像的打包部署Docker镜像的打包部署的全部内容,希望文章能够帮你解决Docker镜像的打包部署Docker镜像的打包部署所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部