Docker 基于已有镜像的容器创建镜像

Docker 基于已有镜像的容器创建镜像:


docker:/root# docker run -it januswel/centos  /bin/bash


 
docker exec -it januswel/centos  /bin/bash


docker:/root# docker start 13fe7a3f05cc
13fe7a3f05cc


后台运行:
docker:/root# docker exec -it 13fe7a3f05cc /bin//bash
[root@13fe7a3f05cc /]# 



docker:/root# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
13fe7a3f05cc        januswel/centos     "/bin/bash"         3 hours ago         Up About a minute                       boring_torvalds 




查看容器版本:

[root@13fe7a3f05cc /]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core)

[root@13fe7a3f05cc /]# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 0.0.0.0
        inet6 fe80::42:acff:fe11:2  prefixlen 64  scopeid 0x20<link>
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 7115  bytes 10516479 (10.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3546  bytes 236182 (230.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 16436
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@13fe7a3f05cc /]# ping 192.168.32.101
PING 192.168.32.101 (192.168.32.101) 56(84) bytes of data.
64 bytes from 192.168.32.101: icmp_seq=1 ttl=63 time=3.00 ms
64 bytes from 192.168.32.101: icmp_seq=2 ttl=63 time=0.359 ms



保存更改的镜像:

docker:/root# docker commit -m "centos_with_nettools_and_wget" -a "scan" 13fe7a3f05cc  centos_with_net:scan
92b2e7f857ae6b84c6b2484ece2ad7e3f4e35137a2210a0e5944906099c12e67
docker:/root# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos_with_net     scan                92b2e7f857ae        8 seconds ago       269.5 MB
januswel/centos     latest              088820de4929        12 days ago         198.3 MB
linux123            xxx123              088820de4929        12 days ago         198.3 MB
linux123            jj                  088820de4929        12 days ago         198.3 MB
linux123            latest              088820de4929        12 days ago         198.3 MB


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

scan724

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值