A docker related commands
1. Install docker
https://docs.docker.com/install/linux/docker-ce/centos/#install-using-the-repository
sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2
sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker docker it is containerd.io-cli
2. Upload the image to the mirror warehouse
# Landing mirroring warehouse Docker the Login Repository # mark Image Docker Tag Image Repository: Tag # Posted Image Docker the Push Repository: Tag
3. Pull the mirror
docker pull images_name
4. Review existing docker mirror
docker images
5. View Help
docker command --help
6. Find Mirror
docker search image_name
7. Remove Mirror
docker rmi image_name
8. Start the container
https://docs.docker.com/engine/reference/run/
docker run --name=container_name images
9. Check container port mappings
docker port container_id
10. Review of the container running
docker ps
11. View all containers
docker ps -a
12. The dynamic view of the container log
docker logs -f container_name
13 into the container
Use # Docker containers into the docker attach
docker attach CONTAINER_NAME
# Docker into the container using the docker exec
docker exec -it container ID / bin / bash
14. Quit container
# After exiting the container is exited state
exit
after exit # container still remains started
Ctrl + the p-q +
15. Delete the container
docker rm contain_id/container_name
16. A copy of the file
# From the inside of the container copy the file to the host # in the host which execute the following commands Docker CP container name: to copy files in the path of the container which is to be copied to the corresponding path sink host # from the host copy the file to the container inside # in Run the following commands which the host Docker CP to copy the file path name of the container: a path inside the container to be copied to the corresponding
17. Review the docker network
docker network ls
18. Create a network my-docker docker
docker network create -d bridge \ --subnet=192.168.0.0/24 \ --gateway=192.168.0.100 \ --ip-range=192.168.0.0/24 \ my-docker
19. View container pid
Method # a: Docker Top CONTAINER_NAME # Method two: Docker Inspect --format " {} {} .State.Pid " CONTAINER_NAME
Two docker Frequently Asked Questions
1. Docker 安装后 报 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Solution:$ sudo systemctl daemon-reload
$ sudo service docker restart