Before using docker, we need to understand three core concepts of docker: mirror, container and warehouse.
This chapter mainly introduces the use of docker mirrors. There are too many concepts on the Internet.
View mirror information
After installing the docker service, we started the test docker and ran hello-world, saving the hello-world image locally.
[root@hw-biz-alpha admin]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest fce289e99eb9 7 months ago 1.84kB
Getting Mirror
docker pull NAME[:TAG]
With TAG, we can specify the pulled mirror version.
The default value of TAG is latest. For example: docker pull Ubuntu is actually docker pull ubuntu:latest
Get the ubuntu image without specifying TAG. Get the latest version by default
docker pull ubuntu
Once you get it, look at the image information again, and you can see the ubuntu image with an additional latest tag
[root@hw-biz-alpha admin]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 3556258649b2 2 weeks ago 64.2MB hello-world latest fce289e99eb9 7 months ago 1.84kB
Get the Ubuntu image of the specified TAG, such as docker pull ubuntu:14.04, and review the image information again
[root@hw-biz-alpha admin]# docker pull ubuntu:14.04 14.04: Pulling from library/ubuntu a7344f52cb74: Pull complete 515c9bb51536: Pull complete e1eabe0537eb: Pull complete 4701f1215c13: Pull complete Digest: sha256:2f7c79927b346e436cc14c92bd4e5bd778c3bd7037f35bc639ac1589a7acfa90 Status: Downloaded newer image for ubuntu:14.04 docker.io/library/ubuntu:14.04 [root@hw-biz-alpha admin]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 3556258649b2 2 weeks ago 64.2MB ubuntu 14.04 2c5e00d77a67 2 months ago 188MB hello-world latest fce289e99eb9 7 months ago 1.84kB
Run the container created by the mirror
docker run
Run the latest Ubuntu image (specify TAG if you want to run the specified version, such as ubuntu:14.04)
sudo docker run -t -i ubuntu /bin/bash
[root@hw-biz-alpha admin]# docker run -i -t ubuntu /bin/bash root@3f82741ff5d8:/# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var root@3f82741ff5d8:/# exit exit [root@hw-biz-alpha admin]#
parameter
- i turns on input
- t opens a terminal connecting the inside of the container.
- The meaning of t-i is that if you just start a linux system, what can you do without a terminal? If you have a terminal but no input operation, you can't do anything! Of course, if you just want to run quietly in the background, you don't need the - t -i parameter. For example, if I start my own server daemon, you only need the background operation, then you don't need the - t -i parameter.
Here, / bin/bash means to execute the command after starting the container. / bin/bash
Dockerfile's CMD ["/bin/bash"] is also specified to execute the / bin/bash command after the container is started. Dockerrun specifies that the start-up command will override Dockerfile's CMD.
Searching for Mirrors
docker serch TERM, for example: docker serch ubuntu
Parameters:
automated=false only shows auto-created
no-trunc=false does not truncate the output information, which means that the number of words is overused. Replacement information
- s, - start = n outputs mirrors of more than n stars
[root@hw-biz-alpha admin]# docker search ubuntu NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Debian-based Linux operating sys... 9817 [OK] dorowu/ubuntu-desktop-lxde-vnc Docker image to provide HTML5 VNC interface ... 331 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi... 227 [OK] consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC session... 186 [OK] ubuntu-upstart Upstart is an event-based replacement for th... 99 [OK] ansible/ubuntu14.04-ansible Ubuntu 14.04 LTS with ansible 97 [OK] neurodebian NeuroDebian provides neuroscience research s... 58 [OK] 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 50 [OK] ubuntu-debootstrap debootstrap --variant=minbase --components=m... 40 [OK] i386/ubuntu Ubuntu is a Debian-based Linux operating sys... 18 1and1internet/ubuntu-16-apache-php-5.6 ubuntu-16-apache-php-5.6 14 [OK] ppc64le/ubuntu Ubuntu is a Debian-based Linux operating sys... 13 1and1internet/ubuntu-16-apache-php-7.0 ubuntu-16-apache-php-7.0 13 [OK] eclipse/ubuntu_jdk8 Ubuntu, JDK8, Maven 3, git, curl, nmap, mc, ... 11 [OK] 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mariadb-10 ubuntu-16-nginx-php-phpmyadmin-mariadb-10 11 [OK] 1and1internet/ubuntu-16-nginx-php-5.6 ubuntu-16-nginx-php-5.6 8 [OK] 1and1internet/ubuntu-16-nginx-php-5.6-wordpress-4 ubuntu-16-nginx-php-5.6-wordpress-4 7 [OK] 1and1internet/ubuntu-16-apache-php-7.1 ubuntu-16-apache-php-7.1 6 [OK] darksheer/ubuntu Base Ubuntu Image -- Updated hourly 5 [OK] 1and1internet/ubuntu-16-nginx-php-7.0 ubuntu-16-nginx-php-7.0 4 [OK] pivotaldata/ubuntu A quick freshening-up of the base Ubuntu doc... 2 1and1internet/ubuntu-16-php-7.1 ubuntu-16-php-7.1 1 [OK] smartentry/ubuntu ubuntu with smartentry 1 [OK] 1and1internet/ubuntu-16-sshd ubuntu-16-sshd 1 [OK] pivotaldata/ubuntu-gpdb-dev Ubuntu images for GPDB development 0
delete mirror
docker rmi REPOSITORY:TAG or docker rmi IMAGEID
Deleting a specific version of the image does not affect the latest image