Docker Cleanup Command Collection

Source: Internet
Author: User
Tags commit docker ps docker run

Kill all the containers that are running Docker kill $ (Docker ps-a-Q)

Remove all stopped containers (Docker RM does not have the-f parameter, the running container will not be deleted) Docker RM $ (Docker ps-a-Q)

Delete all non-dangling tagged images docker rmi $ (Docker images-q-F Dangling=true)

If you want to delete untagged images, which is the image with ID <None>, you can use

Docker RMI $ (Docker images | grep "^<none>" | awk "{PRINT $ 3} ")

Remove all mirrors Docker rmi $ (Docker images-q)

Create aliases for these commands # ~/.bash_aliases

# Kill all the containers that are running.
Alias Dockerkill= ' Docker kill $ (Docker ps-a-Q) '

# Remove all containers that have been stopped.
Alias Dockercleanc= ' Docker rm $ (Docker ps-a-Q) '

# Remove all non-tagged mirrors.
Alias Dockercleani= ' Docker RMI $ (Docker images-q-f dangling=true) '

# Remove all stopped containers and non-tagged mirrors.
Alias dockerclean= ' Dockercleanc | | True && Dockercleani '

Also attached is the Docker Common command

Docker version #查看版本

Docker search tutorial# searching for available docker images

Docker Pull Learn/tutorial #下载镜像

Docker run learn/tutorial echo "Hello word" #在docker容器中运行hello world!

Docker run learn/tutorial apt-get install-y ping# Installing a new program in a container

Save Image

First use the Docker ps-l command to obtain the ID of the container after the ping command is installed. Then save this image as learn/ping.
Tips:
1. Run Docker commit to view a list of parameters for this command.
2. You need to specify the ID of the Save container to submit. (Translator Press: obtained via Docker ps-l command)
3. There is no need to copy the full ID, usually the first three to four letters can be distinguished. (Translator Press: Very similar to git version number)
The correct command:
Docker commit 698 Learn/ping

Run a new image

Docker Run lean/ping Ping www.google.com

Check for images in operation

Now that you've run a Docker container, let's look at the running container.
Use the Docker PS command to see a list of all the containers that are running, and with the Docker inspect command we can view more detailed information about a particular container.
Goal:

Find the ID of a running container, and then use the Docker Inspect command to view the container's information.
Tips:

You can use the previous part of the mirror ID, which does not require a full ID.
The correct command:
Docker inspect Efe

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.