docker- set of common commands

①. Dependencies required for installation
1 sudo yum install -y yum-utils device-mapper-persistent-data lvm2
view of the domestic network problems, it is strongly recommended to use domestic source! ! !

Domestic Source:

1 sudo yum-config-manager --add -repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
official source:

1 sudo yum-config-manager --add -repo https://download.docker.com/linux/centos/docker-ce.repo
If you need to test versions of Docker CE use the following command:

1 sudo yum-config-manager --enable docker-ce-test
if required nightly builds of Docker CE use the following command:

1 sudo yum-config-manager --enable docker-ce-nightly
②.更新yum缓存并安装Docker-ce
1 sudo yum makecache fast
2 sudo yum -y install docker-ce
③.启动Docker-ce
sudo systemctl enable docker
sudo systemctl start docker


--------- My Ali cloud acceleration
sudo mkdir -p / etc / Docker
sudo TEE /etc/docker/daemon.json << - 'EOF'
{
"Registry-Mirrors": [ "HTTPS: / /m0vkwn4c.mirror.aliyuncs.com "]
}
the EOF
the sudo systemctl-daemon reload
the sudo systemctl the restart Docker

 


Command --- ---- ------- docker popular
search image
docker search image name

Download Mirror
docker pull Mirror

View Mirror list of installed
docker images

Remove a mirror
docker rmi image id

Run-time image to generate a new container
docker run -d -it mirror name: version number
EG: docker run -d -it -p 8080: 8080 Tomcat:. 7
-p port mapping, the former host port, which port the container, a plurality of 8080 port -p: 8080 -p 9090: 9090
-d background container
-it run container in interactive mode
eg: docker run -d -it -p 8080 : 8080 --name test -v / opt: / opt tomcat: 7
-v data loading

into the container
docker exec -it container id / bin / bash

Start container stop
id docker start container
docker stop container id

Delete container
docker rm container id

View container logs
docker logs container id -f

docker plug-in to a folder
docker run -v
example
docker run -v / usr / ToolsAPIDir: / ToolsAPIDir1 -d -p 5005: 5004 -it toolsapi: v8 python3 tools_api.py
command parsing:
-v local directory: container directory. Mount host local directory / usr / ToolsAPIDir directory to the container / ToolsAPIDir1 directory, local directory path must be an absolute path
-d background container
-p 5005: 5004 specifies the mapping of host port 5005 to 5004 container port
-it toolsapi : v8 running in interactive mode toolsapi: v8 initiated container
python3 tools_api.py start api.py file, so you can not specify another Dockfile command CMD, or a command CMD is covered Dockfile.

Guess you like

Origin www.cnblogs.com/daysn/p/12102575.html