docker 创建镜像

docker:/root# docker search centos
NAME                            DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
centos                          The official build of CentOS.                   2028      [OK]       
jdeathe/centos-ssh              CentOS-6 6.7 x86_64 / CentOS-7 7.2.1511 x8...   17                   [OK]
jdeathe/centos-ssh-apache-php   CentOS-6 6.7 x86_64 / Apache / PHP / PHP M...   14                   [OK]
million12/centos-supervisor     Base CentOS-7 with supervisord launcher, h...   9                    [OK]
blalor/centos                   Bare-bones base CentOS 6.5 image                8                    [OK]
nimmis/java-centos              This is docker images of CentOS 7 with dif...   7                    [OK]
torusware/speedus-centos        Always updated official CentOS docker imag...   7                    [OK]
nickistre/centos-lamp           LAMP on centos setup                            3                    [OK]
nathonfowlie/centos-jre         Latest CentOS image with the JRE pre-insta...   3                    [OK]
centos/mariadb55-centos7                                                        3                    [OK]
consol/sakuli-centos-xfce       Sakuli end-2-end testing and monitoring co...   2                    [OK]
timhughes/centos                Centos with systemd installed and running       1                    [OK]
lighthopper/orientdb-centos     A Dockerfile for creating an OrientDB imag...   1                    [OK]
layerworx/centos                CentOS container with etcd, etcdctl, confd...   1                    [OK]
yajo/centos-epel                CentOS with EPEL and fully updated              1                    [OK]
pacur/centos-7                  Pacur CentOS 7                                  1                    [OK]
darksheer/centos                Base Centos Image -- Updated hourly             1                    [OK]
pacur/centos-6                  Pacur CentOS 6                                  1                    [OK]
softvisio/centos                Centos                                          1                    [OK]
ustclug/centos                   USTC centos                                    0                    [OK]
blacklabelops/centos            CentOS Base Image! Built and Updates Daily!     0                    [OK]
jsmigel/centos-epel             Docker base image of CentOS w/ EPEL installed   0                    [OK]
lighthopper/openjdk-centos      A Dockerfile for creating an OpenJDK image...   0                    [OK]
grayzone/centos                 auto build for centos.                          0                    [OK]
januswel/centos                 yum update-ed CentOS image                      0                    [OK]
docker:/root# docker pull centos
latest: Pulling from centos
47d44cb6f252: Pull complete 
6fdebd7b0eb5: Pull complete 
a63aae4d216f: Pull complete 
bb3d629a7cbc: Pull complete 
Digest: sha256:381f21e4c7b3724c6f420b2bcfa6e13e47ed155192869a2a04fa10f944c78476
Status: Downloaded newer image for centos:latest

docker:/root# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos_with_net     scan                92b2e7f857ae        28 minutes ago      269.5 MB
januswel/centos     latest              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
linux123            xxx123              088820de4929        12 days ago         198.3 MB
centos              latest              bb3d629a7cbc        12 days ago         196.6 MB


docker:/root#  docker run -itd centos  /bin/bash
c0dfbb37f8415e2faa18a30d5f33d955d73fdbdfb2f4f62f72fa83775249816c


进入容器:


docker exec -it januswel/centos  /bin/bash

docker:/root# docker exec -it c0dfbb37f841  /bin/bash
[root@c0dfbb37f841 /]# 
[root@c0dfbb37f841 /]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 



下载Centos 6.5版本:

docker:/root# docker search centos

docker:/root# docker run -itd blalor/centos  /bin/bash
40d30fb0fc60d43a343e199db0df70104f70eac02a044f599208fe196c5da3b0



docker:/root# docker exec -it c0895b3b9477  /bin/bash


bash-4.1# cat /etc/redhat-release 
CentOS release 6.5 (Final)
bash-4.1# 



创建Centos 6.5的镜像:


保存更改的镜像:

docker:/root# docker commit -m "centos_with_nettools" -a "scan" c0895b3b9477  centos_6.5_net:scan

原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6200316.html