Docker Cleanup Command Collection _docker

Source: Internet
Author: User
Tags docker ps docker run

Kill all the containers that are running

Copy Code code as follows:
Docker kill $ (Docker ps-a-Q)

Delete all containers that have stopped

Copy Code code as follows:
Docker RM $ (Docker ps-a-Q)

Delete all mirrors that are not labeled dangling

Copy Code code as follows:
Docker RMI $ (Docker images-q-F Dangling=true)

Remove all mirrors

Copy Code code as follows:
Docker RMI $ (Docker images-q)

Create aliases for these commands

Copy Code code as follows:
# ~/.bash_aliases

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

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

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

# Delete all containers that have been stopped and mirrors that are not tagged.
Alias dockerclean= ' Dockercleanc | | True && Dockercleani '

Attached Docker common commands

Docker version #查看版本

Docker search tutorial# available docker mirrors

Docker Pull Learn/tutorial #下载镜像

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

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

Save Mirror

First use the Docker ps-l command to obtain the ID of the container after the ping has been installed. Then save the image as a learn/ping.
Tips:
1. Run Docker commit to view the list of arguments for the command.
2. You need to specify the ID of the storage container to be submitted. (translator: obtained by Docker ps-l command)
3. There is no need to copy the full ID, usually the beginning of the three to four letters can be distinguished. (Translator: Very similar to git inside version number)
The correct command:
Docker commit 698 Learn/ping

Running a new mirror

Docker Run lean/ping Ping www.google.com

To check for mirroring in a run

Now that you have run a Docker container, let's look at the container that is running.
Use the Docker PS command to view all the running container lists and use the Docker inspect command to view more detailed information about a container.
Goal:

Locate 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 section of the mirror ID, and you do not need the full ID.
The correct command:
Docker inspect Efe

PS is still in the development phase, not recommended to deploy to the production environment, continue to wait and see ...

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.