操作环境
Centos 7
Docker version 17.03.0-ce, build 3a232c8
操作步骤
下载image
如下载Centos6 image,下述命令表示下载Centos集中的Centos6,如果直接键入docker pull centos,则下载Centos集中的laste tag的image
[root@localhost ~]# docker pull centos:centos6
centos6: Pulling from library/centos
c57dd33ddf56: Pull complete
Digest: sha256:7aa75b333f36c5e06c8aad574000a59c746edff8030d32214cea22db4540699e
Status: Downloaded newer image for centos:centos6
如下载ubuntu image
[root@localhost ~]# docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
d54efb8db41d: Pull complete
f8b845f45a87: Pull complete
e8db7bf7c39f: Pull complete
9654c40e9079: Pull complete
6d9ef359eaaa: Pull complete
Digest: sha256:dd7808d8792c9841d0b460122f1acf0a2dd1f56404f8d1e56298048885e45535
Status: Downloaded newer image for ubuntu:latest
列出image
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos centos6 ae5cb7280ec3 5 days ago 195 MB
centos latest 98d35105a391 5 days ago 192 MB
registry latest 047218491f8c 2 weeks ago 33.2 MB
alpine latest 4a415e366388 2 weeks ago 3.98 MB
ubuntu latest 0ef2e08ed3fa 3 weeks ago 130 MB
hello-world latest 48b5124b2768 2 months ago 1.84 kB
shipyard/shipyard latest 36fb3dc0907d 5 months ago 58.8 MB
shipyard/rethinkdb latest 4841f0ad4547 21 months ago 296 MB
自定义创建image
此处通过docker commit自定义创建含有httpd服务的Centos6
1.启动一个Centos6 container
[root@localhost ~]# docker run -i -t ae5cb7280ec3 /bin/bash
[root@7c5ad4028679 /]#
2.安装httpd
[root@7c5ad4028679 /]# yum -y install httpd
[root@7c5ad4028679 /]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2 for ServerName
[ OK ]
[root@7c5ad4028679 /]# chkconfig httpd on
3.通过docker commit创建含有httpd服务的centos6 image
[root@localhost ~]# docker commit 7c5ad4028679 centos6-httpd
sha256:4a267ee811d7f5f6b1f5d00d66c62b382adc0be7e80787c7993ede6cce35190f
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos6-httpd latest 4a267ee811d7 50 seconds ago 311 MB
centos centos6 ae5cb7280ec3 5 days ago 195 MB
centos latest 98d35105a391 5 days ago 192 MB
registry latest 047218491f8c 2 weeks ago 33.2 MB
alpine latest 4a415e366388 2 weeks ago 3.98 MB
ubuntu latest 0ef2e08ed3fa 3 weeks ago 130 MB
hello-world latest 48b5124b2768 2 months ago 1.84 kB
shipyard/shipyard latest 36fb3dc0907d 5 months ago 58.8 MB
shipyard/rethinkdb latest 4841f0ad4547 21 months ago 296 MB
查找image
如查找关于mysql的image
[root@localhost ~]# docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relati... 4046 [OK]
mysql/mysql-server Optimized MySQL Server Docker images. Crea... 280 [OK]
centurylink/mysql Image containing mysql. Optimized to be li... 49 [OK]
sameersbn/mysql 44 [OK]
zabbix/zabbix-server-mysql Zabbix Server with MySQL database support 30 [OK]
zabbix/zabbix-web-nginx-mysql Zabbix frontend based on Nginx web-server ... 15 [OK]
appcontainers/mysql Centos/Debian Based Customizable MySQL Con... 8 [OK]
marvambass/mysql MySQL Server based on Ubuntu 14.04 7 [OK]
dnhsoft/mysql-utf8 Inherits the official MySQL image configur... 5 [OK]
frodenas/mysql A Docker Image for MySQL 3 [OK]
alterway/mysql Docker Mysql 3 [OK]
bitnami/mysql Bitnami MySQL Docker Image 3 [OK]
yfix/mysql Yfix docker built mysql 2 [OK]
debezium/example-mysql Example MySQL database server with a simpl... 2 [OK]
drupaldocker/mysql MySQL for Drupal 2 [OK]
lysender/mysql MySQL base image using Ubuntu 16.04 Xenial 1 [OK]
coscale/mysql CoScale custom configuration of the offici... 1 [OK]
newrelic/mysql-plugin New Relic Plugin for monitoring MySQL data... 1 [OK]
tozd/mysql MySQL (MariaDB fork) Docker image. 1 [OK]
projectomakase/mysql Docker image for MySQL 0 [OK]
cloudposse/mysql Improved `mysql` service with support for ... 0 [OK]
treenity/mysql Mysql5.7 with OSx permission fixs 0 [OK]
captomd/mysql CaptoMD mysql configuration 0 [OK]
nanobox/mysql MySQL service for nanobox.io 0 [OK]
datajoint/mysql MySQL image pre-configured to work smoothl... 0 [OK]
删除image
[root@localhost ~]# docker rmi 9c3ac4d67e85
Untagged: centos6-ssh-nginx-mysql:latest
Deleted: sha256:9c3ac4d67e85108a22bf73597e5afaf2b8d0b1da1b0653c4a49b4f92784e32a5
Deleted: sha256:b3a01d5f6936c97e488a074808331259ee210a6f221082f9a79ccdd7fd3c563f