标签:free cer soft osi attach 自己的 get stack ant
List Images
列出本地所有Docker image
- # docker images
- REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
- centos centos6 25c5298b1a36 2 weeks ago 215.8 MB
可以看到,REPOSITORY是image来源库,此处是centos
TAG:每个image有自己的tag,此处是centos6
使用该image启动Docker Container的时候,名字为:centos:centos6
IMAGE ID:每个image有自己独立的ID
下载新的image
查找新的image
众多Docker的使用者会创建自己的image,有部分image就会上传到Docker Hub中,我们可以直接在Docker Hub中查找合适的image。
也可以使用docker search
命令查找image
- # docker search centos | more
- NAME DESCRIPTION STARS OFFICIAL AUTOMATED
- centos The official build of CentOS. 685 [OK]
- tianon/centos CentOS 5 and 6, created using rinse instea... 29
- ansible/centos7-ansible Ansible on Centos7 22 [OK]
- ariya/centos6-teamcity-server TeamCity Server 8.1 on CentOS 6 8 [OK]
- tutum/centos Centos image with SSH access. For the root... 8 [OK]
- berngp/docker-zabbix Runs Zabbix Server and Zabbix Web UI on a ... 8 [OK]
- saltstack/centos-6-minimal 8 [OK]
- blalor/centos Bare-bones base CentOS 6.5 image 7 [OK]
- centos/freeipa FreeIPA in Docker on CentOS 7
- steeef/graphite-centos CentOS 6.x with Graphite and Carbon via ng... 6 [OK]
- dockerfiles/centos-lamp 6 [OK]
- gluster/gluster GlusterFS 3.5 - CentOS 6.5 Docker repo 6 [OK]
- ariya/centos6-teamcity-agent Build agent for TeamCity 8.1 5 [OK]
- tutum/centos-6.4 DEPRECATED. Use tutum/centos:6.4 instead. ... 5 [OK]
- jdeathe/centos-ssh-apache-php CentOS-6 6.5 x86_64 / Apache / PHP / PHP m... 5 [OK]
- cern/centos-wlcg-wn CentosOS 6 image with pre-installed softwa... 4
创建新的image
更新现有的image
交互模式启动centos:centos6,安装MySQL
- # docker run -t -i centos:centos6 /bin/bash
- bash-4.1#
- bash-4.1# yum install -y mysql mysql-serve
完成后,exit
退出交互模式
- # docker ps -a
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- 2e9de4d9c350 centos:centos6 /bin/bash 2 minutes ago Exited (0) 7 seconds ago mad_colden
可以看到刚刚关掉的container ID
- # docker commit -m="install mysql" -a="Hongtu Zang" 2e9de4d9c350 centos6:hongtu
- 5f3bca7952cac8900e08b5fac11cdd1a4941803edbb5442593a171fe574ed961
-m Message,描述信息
-a author,image的创建者
- # docker images
- REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
- centos6 hongtu 5f3bca7952ca About a minute ago 320.3 MB
- centos centos6 25c5298b1a36 2 weeks ago 215.8 MB
可以看到,多出来一个TAG为hongtu的image,是我们刚刚创建好的
从Dockerfile创建image
创建一个Dockerfile
- # mkdir hongtu
- # cd hongtu/
- # touch Dockerfile
编辑Dockerfile内容:
- # This is a comment
- FROM centos:centos6
- MAINTAINER Hongtu Zang <hongtu_zang@chinacloudly.com>
- RUN yum install -y mysql mysql-server
FROM 基础image
MAINTAINER 作者
RUN 需要执行的命令,此处是安装mysql-server
docker run
创建新的模板
成功创建新的image
-t
定义image属性,属于 hongtu
用户,repository
为 centos
, tag
指定为 v2
.
指定在当前目录寻找 Dockerfile
- # docker images
- REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
- hongtu/centos6 v2 4ee0c1aacb0e 2 minutes ago 323.1 MB
- centos6 hongtu 5f3bca7952ca 31 minutes ago 320.3 MB
- centos centos6 25c5298b1a36 2 weeks ago 215.8 MB
可以看到新建的image id 为 4ee0c1aacb0e
向Docker hub上传 image
- # docker push hongtu/centos6
删除本地image
- # docker rmi -f hongtu/centos6
-f
强制删除
三、 Docker Image操作
标签:free cer soft osi attach 自己的 get stack ant
原文地址:http://www.cnblogs.com/mfc-itblog/p/6697011.html