docker如何将容器做出镜像?做出镜像可以使用commit命令或dockerfile的方式,commit命令比较简单,相当于docker根据container内部执行的命令自动生成dockerfile,并进行了build,比较适合对dockerfile不熟悉的用户;dockerfile比较适合批量处理的场景。
使用docker commit命令做镜像
1. pull一个centos6.6的基础镜像,并运行一个docker container,然后在其中进行定制化(安装、配置服务等);
[root@localhost ~]# docker pull centos:6.6
pulling repository centos
8b44529354f3: download complete
f1b10cd84249: download complete
status: downloaded newer image for centos:6.6
[root@localhost ~]# docker images
repository????????? tag???????????????? image id??????????? created???????????? virtual size
centos????????????? 6.6???????????????? 8b44529354f3??????? 4 days ago????????? 202.6 mb
centos????????????? centos6.6?????????? 8b44529354f3??????? 4 days ago????????? 202.6 mb
[root@localhost ~]# docker run -i -t centos:6.6 bash
[root@b42c1ba929a9 /]# ls
bin? dev? etc? home? lib? lib64? lost+found? media? mnt? opt? proc? root? sbin? selinux? srv? sys? tmp? usr? var
[root@b42c1ba929a9 /]# mkdir /tmp/test.txt
[root@b42c1ba929a9 /]# exit
exit接下来,查看一下container的改动:
[root@localhost ~]# docker ps -a
container id??????? image?????????????? command???????????? created????????????? status????????????????????? ports?????????????? names
b42c1ba929a9??????? centos:6.6????????? bash????????????? about a minute ago?? exited (0) 22 seconds ago?????????????????????? berserk_mcclintock
804a56ce8008??????? f1b10cd84249??????? /bin/echo hello?? 22 minutes ago?????????????????????????????????????????????????????? test
[root@localhost ~]# docker diff b42c1ba929a9
c /tmp
a /tmp/test.txt
c /root
a /root/.bash_history2. 执行docker commit命令创建一个镜像:
[root@localhost ~]# docker commit -m new container b42c1ba929a9 yuanhuan/newcontainer1
07b146e0be9e98c253122784c3837dd1604f7692e794f3601dad747d41901cd4
[root@localhost ~]# docker images
repository?????????????? tag???????????????? image id??????????? created???????????? virtual size
yuanhuan/newcontainer1?? latest????????????? 07b146e0be9e??????? 43 seconds ago????? 202.6 mb
centos?????????????????? 6.6???????????????? 8b44529354f3??????? 4 days ago????????? 202.6 mb
centos?????????????????? centos6.6?????????? 8b44529354f3??????? 4 days ago????????? 202.6 mb3. 登录docker,并将该镜像push到docker仓库:
[root@localhost ~]# docker login
username: yuanhuan
password:
email: yuanhuan_2005@126.com
login succeeded
[root@localhost ~]# docker push yuanhuan/newcontainer1
the push refers to a repository [yuanhuan/newcontainer1] (len: 1)
sending image list
pushing repository yuanhuan/newcontainer1 (1 tags)
f1b10cd84249: image already pushed, skipping
8b44529354f3: image already pushed, skipping
07b146e0be9e: image successfully pushed
pushing tag for rev [07b146e0be9e] on {https://cdn-registry-1.docker.io/v1/repositories/yuanhuan/newcontainer1/tags/latest}作者:网易云社区;来源:简书;链接:https://www.jianshu.com/p/6d85f32c2e35
西部数码的容器云产品是通过docker技术,在云计算集群服务器上部署容器云服务实现,功能强大、简单易用,可自由选择网络计费方式,可作集群服务,自由搭建私有网络。
高性价比的容器云产品链接 https://www.west.cn/paas/container/
备案的域名可以换服务器吗?如何查看域名备案?怎么买便宜阿里云服务器套餐云端服务器相关优惠价格和ecs云服务器2相关的问题商标查询 收费标准那个云服务器比较便宜这个网站请问这种怎么处理.hk域名 注册需要哪些条件?