uname -r
3.10.0- 693.11.1. el7.x86_64
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
File "/bin/yum-config-manager", line 135
except yum.Errors.RepoError, e:^
SyntaxError: invalid syntax
133 try:134 opts = yb.doUtilConfigSetup()135 except yum.Errors.RepoError as e:136 logger.error(str(e))137 sys.exit(50)
File "/bin/yum-config-manager", line 159
print yb.fmtSection('main')^
SyntaxError: invalid syntax
159 print(yb.fmtSection('main'))160print(yb.conf.dump())
239: except(IOError, OSError, yum.Errors.YumBaseError)as e:254: except yum.Errors.DuplicateRepoError as e:261: except ValueError as e:272:except(IOError, OSError)as e:
You must ensure that the yum package is up to date before installation
yum update
Download and execute the installation docker script
download: curl -fsSl https://get.docker.com -o get-docker.sh
carried out: sudo sh get-docker.sh
sudo systemctl start docker
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1 b930d010525: Pull complete
Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly
Before Docker runs the container, the corresponding image needs to exist locally.
The image is used to create Docker containers. An image can contain a complete operating system environment and other applications required by users. There are a large number of ready-made images available for download in Docker Hub. Docker images are read-only, and one image can create multiple containers.
Docker uses containers to develop and run applications.
A container is a real column created by an image. It can be started, started, stopped, and deleted. Each container is isolated from each other to ensure a safe platform.
A warehouse is a place where mirror files are stored centrally.
Each warehouse contains multiple mirrors, and each mirror has a different tag (TAG)
The command to get the image is docker pull
format: docker pull [Options][Docker Registry address[:The port number]/]Warehouse name[:label]
use: docker pull ubuntu:18.04
In the above command, the specific mirror warehouse address is not given while pulling the mirror, so the default is to get the mirror from the docker hub, and the mirror name is ubuntu:18.04 mirror, so will get the official mirror library/The label in the ubuntu warehouse is 18.Mirror of 04.
After obtaining the image successfully, run the image next.
Here the ubuntu container is up and running and entered the ubuntu system.
parameter:
docker run command to run the container
- it these are two parameters-i:Interactive operation,-t:terminal
- - The rm container is deleted immediately after exiting to avoid wasting space. By default, the container will not be deleted automatically and needs to be deleted manually.
List all mirrors
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 7698f282e524 2 weeks ago 69.9MB
hello-world latest fce289e99eb9 4 months ago 1.84kB
parameter:
REPOSITORY:warehouse name
TAG:label
IMAGE ID:Mirror ID
CREATED:Creation time
SIZE:take up space
Mirror volume
docker system df
Phantom mirror
< none><none> 00285df0df87 5 days ago 342 MB
This image originally had the image name and label, which was originally mongo:3.2. With the official image maintenance, after the new version was released, when re-docker pull mongo:3.2, the image name of mongo:3.2 was transferred to the newly downloaded image , And the name on the old mirror was cancelled and became
docker image ls -f dangling=true
Dangling mirrors are generally useless and can be deleted. Use the following command to delete the hanging mirrors.
docker image prune
List specified mirrors
docker image ls ubuntu #ubuntu image name
List a specific mirror
docker image ls ubuntu:18.04 # ubuntu:18.04 Mirror name:18.04 Label
Filter out the image created after ubuntu: 18.04 image
docker image ls -f sinc=ubuntu:18.04
Filter out the images created before ubuntu: 18.04
docker image ls -f before=ubuntu:18.04
The mirrored ID shows the number of mirrors
docker image ls -q
# Mirror ID
7698 f282e524
fce289e99eb9
format template syntax to display the specified field
docker image ls --format "{{.ID}}: {{.Repository}}"
# display
7698 f282e524: ubuntu
fce289e99eb9: hello-world
Display the header row, define the column yourself
docker image ls --format "table {{.ID}}\t {{.Repository}}\t{{.Tag}}"
# display
IMAGE ID REPOSITORY TAG
7698 f282e524 ubuntu 18.04
fce289e99eb9 hello-world latest
Delete mirror
Before deleting, the mirror must be stopped before it can be deleted.
docker image rm image ID
Docker runs Nginx
Get the nginx image
sudo docker pull nginx
View the currently running docker image
docker ps
Run Nginx image
sudo docker run -d -p 8000:80--name nginx_test nginx
Enter the Docker running container
docker image ls #View mirror
docker ps #View running containers
docker ps -a #View all containers
docker exec -it webserver container name bash
Recommended Posts