Some best practices in Docker usage

Source: Internet
Author: User
Tags docker ps
This is a creation in Article, where the information may have evolved or changed.

Some best practices in Docker usage

This article will record:

    • Best practices that are organized in the process of using Docker.
    • Other Docker user-published (possibly translated, all with original links) validated best practices.

Therefore, this article will be updated for a long time.

Docker Installation Related

If you use Docker after the installation is complete, the following error occurs:

> Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

Referring to the content here, we need to execute the following command to install AppArmor:

sudo apt-get install apparmor

Docker Usage Related

    • Using Bash Aliases to simplify Docker use commands, inspired by a great article (the site that publishes this article docker.cn is also a good Docker resource station), I've expanded:

Add the following content to the $HOME/.bash_aliases:

# Show all available docker related aliases.aliasdockeraliases=' printf ' \nbelow is all pre-defined docker maintainance Aliases:\n\ndkka | Dockerkillall\tkill All running Containers\ndksa | Dockerstopall\tstop All running CONTAINERS\NDKRC | Dockerremovec\tremove All stopped Containers\ndkri | Dockerremovei\tremove All untagged Images\ndkra | Dockerremovea\tremove all stopped containers and untagged images\n\n "'aliasDkas=' printf ' \nbelow is all pre-defined docker maintainance Aliases:\n\ndkka | Dockerkillall\tkill All running Containers\ndksa | Dockerstopall\tstop All running CONTAINERS\NDKRC | Dockerremovec\tremove All stopped Containers\ndkri | Dockerremovei\tremove All untagged Images\ndkra | Dockerremovea\tremove all stopped containers and untagged images\n\n "' # Kill all running containers.aliasDockerkillall=' printf ' \n>>> killing all running containers\n\n "&& Docker Kill $ (Docker ps-q) && printf" \ n "'aliasDkka=' printf ' \n>>> killing all running containers\n\n "&& Docker Kill $ (Docker ps-q) && printf" \ n "' # Stop all running containers.aliasDockerstopall=' printf ' \n>>> stopping all running containers\n\n "&& Docker stop $ (Docker ps-q) && printf "\ n" 'aliasDksa=' printf ' \n>>> stopping all running containers\n\n "&& Docker stop $ (Docker ps-q) && printf "\ n" ' # Remove all stopped containers.aliasDockerremovec=' printf ' \n>>> removing stopped containers\n\n "&& Docker RM $ (Docker ps-a-Q) && printf" \ n "'aliasDKRC=' printf ' \n>>> removing stopped containers\n\n "&& Docker RM $ (Docker ps-a-Q) && printf" \ n "' # Remove all untagged images.aliasDockerremovei=' printf ' \n>>> removing untagged images\n\n ' && Docker RMI $ (Docker images-q-F dangling=true) & & printf "\ n" 'aliasDkri=' printf ' \n>>> removing untagged images\n\n ' && Docker RMI $ (Docker images-q-F dangling=true) & & printf "\ n" ' # Remove All stopped containers and untagged images.aliasDockerremovea=' Dockerremovec | | true && dockerremovei 'aliasDkra=' Dockerremovec | | true && dockerremovei '

You can then use these aliases by executing "source ~/.bash_aliases" on the command line, such as:

$ dkasBelow are all pre-defined docker maintainance aliases:dkka | dockerkillall    Kill all running containersdksa | dockerstopall    Stop all running containersdkrc | dockerremovec    Remove all stopped containersdkri | dockerremovei    Remove all untagged imagesdkra | dockerremovea    Remove all stopped containers and untagged images

--EOF--

    • Climbing stairs and Fibonacci series →
    • ←ubuntu 14.04 based on the latest OpenSSL compiler curl

Disclaimer: This article uses the BY-NC-SA protocol to authorize. Reprint please specify transfer from: Some best practices in Docker usage

Related Article

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.