查看镜像:
[root@localhost /]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos5 latest 5a7df8dd4d20 22 hours ago 324 MB centos3 latest 5a7df8dd4d20 22 hours ago 324 MB centos4 latest 5a7df8dd4d20 22 hours ago 324 MB centos6 latest 5a7df8dd4d20 22 hours ago 324 MB centos latest 5a7df8dd4d20 22 hours ago 324 MB centos1 latest 5a7df8dd4d20 22 hours ago 324 MB centos2 latest 5a7df8dd4d20 22 hours ago 324 MB [root@localhost /]#搜索镜像:
[root@localhost ~]# 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] softvisio/centos Centos 1 [OK] darksheer/centos Base Centos Image -- Updated hourly 1 [OK] pacur/centos-6 Pacur CentOS 6 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]获取镜像:
[root@localhost ~]# 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 [root@localhost ~]#为镜像设置标签:
[root@localhost ~]# docker tag centos centos123 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos latest bb3d629a7cbc 9 days ago 196.6 MB centos123 latest bb3d629a7cbc 9 days ago 196.6 MB查看运行的镜像:
[root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 807db1718ddd centos "/bin/bash" 2 minutes ago Up 2 minutes high_kirch [root@localhost ~]#启动Docker的容器:
[root@localhost ~]# docker run -t -i centos /bin/bash进入一个容器:
[root@localhost ~]# docker exec -it ccd92ca4baae /bin/bash安装net-tools:
[root@ccd92ca4baae /]# yum install -y net-tools wget Loaded plugins: fastestmirror, ovl base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/4): extras/7/x86_64/primary_db | 101 kB 00:00:00 (2/4): updates/7/x86_64/primary_db | 3.2 MB 00:00:01 (3/4): base/7/x86_64/group_gz | 155 kB 00:00:02 (4/4): base/7/x86_64/primary_db | 5.3 MB 00:00:05 Determining fastest mirrors * base: mirrors.skyshe.cn * extras: mirrors.aliyun.com * updates: mirrors.yun-idc.com Resolving Dependencies --> Running transaction check ---> Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed ---> Package wget.x86_64 0:1.14-10.el7_0.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================= Package Arch Version Repository Size ========================================================================================================================= Installing: net-tools x86_64 2.0-0.17.20131004git.el7 base 304 k wget x86_64 1.14-10.el7_0.1 base 545 k Transaction Summary ========================================================================================================================= Install 2 Packages Total download size: 849 k Installed size: 2.9 M Downloading packages: warning: /var/cache/yum/x86_64/7/base/packages/wget-1.14-10.el7_0.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Public key for wget-1.14-10.el7_0.1.x86_64.rpm is not installed (1/2): wget-1.14-10.el7_0.1.x86_64.rpm | 545 kB 00:00:00 (2/2): net-tools-2.0-0.17.20131004git.el7.x86_64.rpm | 304 kB 00:00:00 ------------------------------------------------------------------------------------------------------------------------- Total 891 kB/s | 849 kB 00:00:00 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-2.1511.el7.centos.2.10.x86_64 (@CentOS) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : net-tools-2.0-0.17.20131004git.el7.x86_64 1/2 Installing : wget-1.14-10.el7_0.1.x86_64 2/2 install-info: No such file or directory for /usr/share/info/wget.info.gz Verifying : wget-1.14-10.el7_0.1.x86_64 1/2 Verifying : net-tools-2.0-0.17.20131004git.el7.x86_64 2/2 Installed: net-tools.x86_64 0:2.0-0.17.20131004git.el7 wget.x86_64 0:1.14-10.el7_0.1 Complete!如何删除一个镜像:
[root@localhost /]# docker rmi centos8 [root@localhost /]# docker rmi centos7:latest查看镜像:
[root@localhost /]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos5 latest 5a7df8dd4d20 22 hours ago 324 MB centos3 latest 5a7df8dd4d20 22 hours ago 324 MB centos4 latest 5a7df8dd4d20 22 hours ago 324 MB centos6 latest 5a7df8dd4d20 22 hours ago 324 MB centos latest 5a7df8dd4d20 22 hours ago 324 MB centos1 latest 5a7df8dd4d20 22 hours ago 324 MB centos2 latest 5a7df8dd4d20 22 hours ago 324 MB [root@localhost /]#