1.Docker镜像常用操作
#Docker 本地镜像
lynn@Utopia:~/data$ sudo docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 83744227b191 3 weeks ago 98.9MB
ubuntu latest 7b9b13f7b9c0 4 weeks ago 118MB
haproxy latest c481d2544260 7 weeks ago 136MB
django latest eb40dcf64078 6 months ago 436MB
#拉取centos镜像
lynn@Utopia:~/data$ sudo docker pull centos
Using default tag: latest
latest: Pulling from library/centos
d5e46245fe40: Pull complete
Digest: sha256:aebf12af704307dfa0079b3babdca8d7e8ff6564696882bcb5d11f1d461f9ee9
Status: Downloaded newer image for centos:latest
#docker已经成功拉取成功
lynn@Utopia:~/data$ sudo docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 83744227b191 3 weeks ago 98.9MB
centos latest 3bee3060bfc8 3 weeks ago 193MB
ubuntu latest 7b9b13f7b9c0 4 weeks ago 118MB
haproxy latest c481d2544260 7 weeks ago 136MB
django latest eb40dcf64078 6 months ago 436MB
#搜索在DockerHub中的CentOS镜像
lynn@Utopia:~/data$ sudo docker search centos
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
centos The official build of CentOS. 3435 [OK]
jdeathe/centos-ssh CentOS-6 6.9 x86_64 / CentOS-7 7.3.1611 x8... 74 [OK]
nimmis/java-centos This is docker images of CentOS 7 with dif... 26 [OK]
gluster/gluster-centos Official GlusterFS Image [ CentOS-7 + Glu... 19 [OK]
kinogmt/centos-ssh CentOS with SSH 15 [OK]
egyptianbman/docker-centos-nginx-php A simple and highly configurable docker co... 9 [OK]
torusware/speedus-centos Always updated official CentOS docker imag... 8 [OK]
nathonfowlie/centos-jre Latest CentOS image with the JRE pre-insta... 6 [OK]
centos/mariadb55-centos7 5 [OK]
consol/sakuli-centos-xfce Sakuli JavaScript based end-2-end testing ... 3 [OK]
darksheer/centos Base Centos Image -- Updated hourly 3 [OK]
harisekhon/centos-java Java on CentOS (OpenJDK, tags jre/jdk7-8) 2 [OK]
harisekhon/centos-scala Scala + CentOS (OpenJDK tags 2.10-jre7 - 2... 2 [OK]
timhughes/centos Centos with systemd installed and running 1 [OK]
blacklabelops/centos CentOS Base Image! Built and Updates Daily! 1 [OK]
vorakl/centos CentOS7, EPEL, tools. Updated/Tested daily! 1 [OK]
freenas/centos Simple CentOS Linux interactive container 1 [OK]
januswel/centos yum update-ed CentOS image 0 [OK]
repositoryjp/centos Docker Image for CentOS. 0 [OK]
vcatechnology/centos A CentOS Image which is updated daily 0 [OK]
smartentry/centos centos with smartentry 0 [OK]
kz8s/centos Official CentOS plus epel-release 0 [OK]
vcatechnology/centos-ci A CentOS image that is used in the VCA Tec... 0 [OK]
grayzone/centos auto build for centos. 0 [OK]
grossws/centos CentOS 6 and 7 base images with gosu and l... 0 [OK]
2.Docker容器常用操作
#启动容器
lynn@Utopia:~/data$ sudo docker run -i -t centos /bin/bash
[root@338a78107666 /]#
#推出容器
[root@338a78107666 /]# exit
exit
#查看正在运行的docker镜像
lynn@Utopia:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9dc37e5f2883 centos "/bin/bash" 42 seconds ago Up 40 seconds angry_pasteur
#进入已经运行的容器
lynn@Utopia:~$ sudo docker attach 9dc37e5f2883
[root@9dc37e5f2883 /]#
#执行运行中的容器命令
lynn@Utopia:~$ sudo docker exec -i -t b93414676e7b ls
anaconda-post.log dev home lib64 media opt root sbin sys usr
bin etc lib lost+found mnt proc run srv tmp var
#停止容器
lynn@Utopia:~$ sudo docker stop b93414676e7b
b93414676e7b
#终止容器
lynn@Utopia:~$ sudo docker kill b93414676e7b
b93414676e7b
#启动容器
lynn@Utopia:~$ sudo docker start b93414676e7b
#重启容器
lynn@Utopia:~$ sudo docker restart b93414676e7b
#删除容器
lynn@Utopia:~$ sudo docker rm b93414676e7b