This is the 9th day of my participation in the August More Text Challenge. For details, see:August is more challenging
Configuration Docker
- Tool Package configuration:
yum install -y yum-utils
- Configure the domestic download source:
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
- Configure the Docker engine:
yum install docker-ce docker-ce-cli containerd.io
- View the Docker version number:
docker --version
Docker’s latest release is currently 20.10.7 - Start the docker:
systemctl start docker
- Pull to test image, hello Docker:
docker run hello-world
So far, the Docker container has been configured. The following are commonly used Docker directives
- Start the docker:
systemctl start docker
- Stop the docker:
systemctl stop docker
- Restart the docker:
systemctl restart docker
- Automatic startup upon startup:
systemctl enable docker
- Check docker status:
systemctl status docker
- Check docker container status:
docker stats
- View docker information:
docker info
- View the Docker documentation:
docker --help
In addition, also need to configure mirror warehouse, there is no existence of Ali
-
Edit the configuration file vim /etc/docker/daemon.json
-
Write the configuration information, save the Settings, and exit
{ "registry-mirrors" : ["http://hub-mirror.c.163.com", "https://docker.mirrors.ustc.edu.cn"] } Copy the code
-
Reload the configuration and restart the Docker service
systemctl daemon-reload
systemctl restart docker
After configuring the address of the domestic image warehouse, you can quickly download large image files
mirror
- Pull mirror image:
Docker pull < image >
- You can specify the version of the image. Otherwise, the latest image is pulled by default
- The downloaded image is stored in the default location
/var/lib/docker
The path
- Viewing a mirror:
docker images
- REPOSITORY: image name
- TAG: mirror TAG
- IMAGE ID: uniquely identifies an IMAGE in the repository
- CREATED: Indicates the time when the image is pulled and CREATED
- SIZE: indicates the SIZE of the mirror
- To delete an image:
Docker rmi < image >
- You can delete the latest mirror by its name and ID. By default, the latest mirror is deleted by its name
- Search image:
Docker search < image >
- NAME: mirror NAME
- DESCRIPTION: Mirror DESCRIPTION
- STARS: Mirror attention
- OFFICIAL: Indicates whether the image is an OFFICIAL authentication image
The docker container provides a detailed description. You can enter docker search –help to view other commands that can be used when searching for images
Container operation
Starting an image generates a container. The relationship between a class and an instance object in Java. In addition, be familiar with the –help help command, can quickly solve the problem
- View the container:
docker ps
By default, view the running containers- a
: View all containers, including stopped and running containers- l
: Looks at the last running container
- Run the container:
Docker run < image >
--name
: Specifies the container name-P
: Creates port mappings randomly-p xxx:xxx
: specifies to establish port mapping. Operating system port: container port-d
: Runs the container in the background
- Start the container:
Docker start < container >
- Stop the container:
Docker stop < container >
- To delete a container:
Docker rm < container >
- The container can be deleted by
CONTAINER ID
,NAMES
Unique identification, rather thanIMAGES
- The container can be deleted by
- Enter the container:
Docker exec -it < container > /bin/bash
There are also less commonly used Docker commands, such as copying files
File copy: docker cp < container >:[container path] [host path]
The last
Note: For the introduction of Docker, there is no reference value