Introduction to DockerDocker is an open source application container engine that allows developers to package their applications and dependencies into a portable image and then publish it to any popular Linux or Windows machine. Using Docker makes it easier to package, test, and deploy applications. Docker environment installation1. Install yum-utils: yum install -y yum-utils device-mapper-persistent-data lvm2 2. Add the docker repository location to the yum source: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo 3. Install docker: yum install docker-ce 4. Start Docker: systemctl start docker Docker image common commandsSearch Mirrordocker search java Download imagedocker pull java:8 How to find the versions supported by the image
Enter the official website of docker hub, address: https://hub.docker.com Then search for the required image: Check the versions supported by the image: Download the image: docker pull nginx:1.17.0 List imagesdocker images Deleting an imageDelete an image by specifying its name docker rmi java:8 Delete an image by specifying its name (mandatory) docker rmi -f java:8 Force delete all images docker rmi -f $(docker images) Docker container common commandsCreate and start a containerdocker run -p 80:80 --name nginx -d nginx:1.17.0 -d option: indicates background operation --name option: specifies the name of the container after running as nginx, and then you can operate the container by name -p option: specifies port mapping, the format is: hostPort:containerPort List ContainersList running containers: docker ps List all containers docker ps -a Stop the container# $ContainerName and $ContainerId can be queried using the docker ps command docker stop $ContainerName(or $ContainerId) for example: docker stop nginx #or docker stop c5f5d5125587 Force stop containerdocker kill $ContainerName(or $ContainerId) Start a stopped containerdocker start $ContainerName(or $ContainerId) Entering the containerFirst query the pid of the container: docker inspect --format "{{.State.Pid}}" $ContainerName(or $ContainerId) Enter the container according to the container's pid: nsenter --target "$pid" --mount --uts --ipc --net --pid Deleting a containerDelete the specified container: docker rm $ContainerName(or $ContainerId) Force delete all containers; docker rm -f $(docker ps -a -q) View the container logsdocker logs $ContainerName(or $ContainerId) View the IP address of the containerdocker logs $ContainerName(or $ContainerId) Synchronize host time to containerdocker cp /etc/localtime $ContainerName(or $ContainerId):/etc/ Check Docker's CPU, memory, network, and IO usage on the host machineView the status of a specified container: docker stats $ContainerName(or $ContainerId) View all containers: docker stats -a Enter bash inside the Docker containerdocker exec -it $ContainerName /bin/bash Modify the storage location of the Docker imageView the storage location of the Docker image: docker info | grep "Docker Root Dir" Shut down the Docker service: systemctl stop docker Move the directory to the target path: mv /var/lib/docker /mydata/docker Create a soft link: ln -s /mydata/docker /var/lib/docker This concludes this article on the essential Docker commands for developers. For more Docker command content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MySQL Basic Tutorial: Detailed Explanation of DML Statements
>>: What you need to know about responsive design
MySQL Views Simply put, a MySQL view is a shortcu...
I believe that many partners who have just come i...
Table of contents 1. Analysis of key source code ...
HTML web page hyperlink tag learning tutorial lin...
What is WSL Quoting a passage from Baidu Encyclop...
Table of contents Version Notes Create a project ...
From the tomcat configuration file, we can see th...
Table of contents Vue this.$store.state.xx.xx Get...
There are two ways to deploy Angular projects wit...
Table of contents 1. Introduction to the basic fu...
1. Disconnection reason There are many reasons wh...
Table of contents Case Context switching overhead...
Importing data with incorrect MySQL character set...
1. Install Docker yum -y install docker-io The &q...
Recently, we received a request for help from a c...