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
Table of contents 1. Introduction 2. Preparation ...
Summary of common operators and operators in java...
Statement 1: <link rel="shortcut icon"...
Data Type: The basic rules that define what data ...
Table of contents 1: Single machine password-free...
As shown below, if it were you, how would you ach...
Usage: date [options]... [+format] or: date [-u|-...
Date-type single-row functions in MySQL: CURDATE(...
Docker runs multiple Springboot First: Port mappi...
This article uses an example to illustrate the pa...
It is very simple to build a kong cluster under t...
1. Construction components 1. A form must contain...
This post introduces a set of free Photoshop wire...
This article uses an example to describe how to r...
As shown below: Mainly execute authorization comm...