Docker Basic Commands (CentOs7 Docker 17.03.1-ce)

Introduction: Please read the official documentation for detailed description of the following commands

【Docker Basic Commands (CentOs7 Docker 17.03.1-ce)】start docker

systemctl start docker.service _
stop docekr
systemctl stop docker.service _
Status check
systemctl status docker.service _
restart docker
systemctl restart docker
Set docker to start on boot
systemctl enable docker

【Docker Basic Commands (CentOs7 Docker 17.03.1-ce)】Cancel startup

systemctl disable docker
View currently started container processes (only view running containers)
docker ps
View all containers, including stopped containers
docker ps -a
stop running a container
docker stop 1f 5f
delete a container
docker rm 1f 5f
【Docker Basic Commands (CentOs7 Docker 17.03.1-ce)】Set docker to start on boot
systemctl enable docker.service
docker stop all running containers
docker stop $(docker ps -a -q)
docker delete all containers
docker rm $(docker ps -a -q)
List all containers that are not running
docker ps -a -f status =exited
Remove all containers that are not running
docker rm $(docker ps -a -f status=exited -q)
docker list all images
docker images
docker delete image (by ID)
docker rmi image_id
docker delete all unused images
docker images -q | xargs docker rmi
docker start the container in the background and mount the external directory
[root@c8d2d852b07ce468594deb20af13b20af-node1 ~] # docker run -d -p 8080:8080 -p 50000:50000 -v /home/ jenkins /data:/var/ jenkins_home jenkins
[root@c8d2d852b07ce468594deb20af13b20af-node1 ~] #
-d to start the background , add -v to mount the external directory, where /home/ jenkins /data is the external directory (Linux file directory)
docker run -d -p 8080 : 8080 -p 50000 : 50000 -v /home/ jenkins /data:/var/ jenkins_home jenkins
above must first create the /home/ jenkins /data directory and grant permissions (cd to the jenkins directory and execute the following command)
chmod 777 *
docker -t command (will allocate terminal)
docker run - it python
(press ctrl+D to exit)

Forcibly delete all mirrors
docker images -q | xargs docker rmi -f

Copyright statement: The content of this article is contributed by Alibaba Cloud real-name registered users. The copyright belongs to the original author. The Alibaba Cloud developer community does not own the copyright and does not assume the corresponding legal responsibility. For specific rules, please refer to the " Alibaba Cloud Developer Community User Service Agreement " and " Alibaba Cloud Developer Community Intellectual Property Protection Guidelines ". If you find any content suspected of plagiarism in this community, fill out the infringement complaint form to report it. Once verified, this community will delete the allegedly infringing content immediately.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us