基于docker commit命令创建
Docker提供了docker commit
命令,支持用户提交自己对定制容器的修改,并生成新的镜像。
命令格式为:docker commit CONTAINER [REPOSITORY[:TAG]]
准备工作
利用ubuntu:14.04镜像创建一个容器:
[root@node1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu latest b44d403a0d52 3 days ago 64.2 MB
docker.io/nginx latest 540a289bab6c 12 days ago 126 MB
docker.io/hello-world latest fce289e99eb9 10 months ago 1.84 kB
[root@node1 ~]#
[root@node1 ~]# docker run -it docker.io/ubuntu /bin/bash
root@b44d403a0d52:/#
更新apt缓存:
更换更新源:
vi /etc/apt/sources.list
#aliyun
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
执行:apt-get update
root@b44d403a0d52:/# apt-get update
Ign http://mirrors.aliyun.com trusty InRelease
Get:1 http://mirrors.aliyun.com trusty-security InRelease [65.9 kB]
Get:2 http://mirrors.aliyun.com trusty-updates InRelease [65.9 kB]
Get:3 http://mirrors.aliyun.com trusty-proposed InRelease [65.9 kB]
Get:4 http://mirrors.aliyun.com trusty-backports InRelease [65.9 kB]
Get:5 http://mirrors.aliyun.com trusty Release.gpg [933 B]