Mar 21, 2015 Tag: Docker

About Docker

About Docker ...

Updated on Dec 23, 2016

Navigate this page:

Introduction

  • Introduction (Youtube) to Docker by Solomon Hykes, 2013-10-02. Easily create lightweight, portable, self-sufficient containers from any application.

Projects

docker-lemp

Docker-Lemp (Github) by Michael Stucki

What does it do?
Run Nginx, php-fpm and MariaDB using [Docker]
Requirements
Install [Docker] and [Compose]
Usage
docker-compose up -d
docker-compose logs
docker-compose stop
docker-compose rm
docker-compose build
docker-compose up --build
Links

other

Incoming

To be read:

Using Docker

  • https://docs.docker.com/engine/tutorials/usingdocker/

  • Common:

    docker ps         Lists containers.
    docker ps --all   Lists containers.
    docker logs       Shows the standard output of a container.
    docker stop       Stops running containers.
    docker info       Display system-wide information.
    docker images     List images.
    

Commands

docker

➜  ~ docker --help
Usage: docker [OPTIONS] COMMAND [arg...]
       docker [ --help | -v | --version ]

A self-sufficient runtime for containers.

Options:

  --config=~/.docker              Location of client config files
  -D, --debug                     Enable debug mode
  -H, --host=[]                   Daemon socket(s) to connect to
  -h, --help                      Print usage
  -l, --log-level=info            Set the logging level
  --tls                           Use TLS; implied by --tlsverify
  --tlscacert=~/.docker/ca.pem    Trust certs signed only by this CA
  --tlscert=~/.docker/cert.pem    Path to TLS certificate file
  --tlskey=~/.docker/key.pem      Path to TLS key file
  --tlsverify                     Use TLS and verify the remote
  -v, --version                   Print version information and quit

Commands:
    attach    Attach to a running container
    build     Build an image from a Dockerfile
    commit    Create a new image from a container's changes
    cp        Copy files/folders between a container and the local filesystem
    create    Create a new container
    diff      Inspect changes on a container's filesystem
    events    Get real time events from the server
    exec      Run a command in a running container
    export    Export a container's filesystem as a tar archive
    history   Show the history of an image
    images    List images
    import    Import the contents from a tarball to create a filesystem image
    info      Display system-wide information
    inspect   Return low-level information on a container, image or task
    kill      Kill one or more running containers
    load      Load an image from a tar archive or STDIN
    login     Log in to a Docker registry.
    logout    Log out from a Docker registry.
    logs      Fetch the logs of a container
    network   Manage Docker networks
    node      Manage Docker Swarm nodes
    pause     Pause all processes within one or more containers
    port      List port mappings or a specific mapping for the container
    ps        List containers
    pull      Pull an image or a repository from a registry
    push      Push an image or a repository to a registry
    rename    Rename a container
    restart   Restart a container
    rm        Remove one or more containers
    rmi       Remove one or more images
    run       Run a command in a new container
    save      Save one or more images to a tar archive (streamed to STDOUT by default)
    search    Search the Docker Hub for images
    service   Manage Docker services
    start     Start one or more stopped containers
    stats     Display a live stream of container(s) resource usage statistics
    stop      Stop one or more running containers
    swarm     Manage Docker Swarm
    tag       Tag an image into a repository
    top       Display the running processes of a container
    unpause   Unpause all processes within one or more containers
    update    Update configuration of one or more containers
    version   Show the Docker version information
    volume    Manage Docker volumes
    wait      Block until a container stops, then print its exit code

Run 'docker COMMAND --help' for more information on a command.

docker-compose

docker-compose --version
docker-compose version 1.9.0, build 2585387

docker-compose --help
Define and run multi-container applications with Docker.

Usage:
  docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
  docker-compose -h|--help

Options:
  -f, --file FILE             Specify an alternate compose file (default: docker-compose.yml)
  -p, --project-name NAME     Specify an alternate project name (default: directory name)
  --verbose                   Show more output
  -v, --version               Print version and exit
  -H, --host HOST             Daemon socket to connect to

  --tls                       Use TLS; implied by --tlsverify
  --tlscacert CA_PATH         Trust certs signed only by this CA
  --tlscert CLIENT_CERT_PATH  Path to TLS certificate file
  --tlskey TLS_KEY_PATH       Path to TLS key file
  --tlsverify                 Use TLS and verify the remote
  --skip-hostname-check       Don't check the daemon's hostname against the name specified
                              in the client certificate (for example if your docker host
                              is an IP address)

Commands:
  build              Build or rebuild services
  bundle             Generate a Docker bundle from the Compose file
  config             Validate and view the compose file
  create             Create services
  down               Stop and remove containers, networks, images, and volumes
  events             Receive real time events from containers
  exec               Execute a command in a running container
  help               Get help on a command
  kill               Kill containers
  logs               View output from containers
  pause              Pause services
  port               Print the public port for a port binding
  ps                 List containers
  pull               Pull service images
  push               Push service images
  restart            Restart services
  rm                 Remove stopped containers
  run                Run a one-off command
  scale              Set number of containers for a service
  start              Start services
  stop               Stop services
  unpause            Unpause services
  up                 Create and start containers
  version            Show the Docker-Compose version information

docker images –help

➜  ~ docker images --help

Usage:    docker images [OPTIONS] [REPOSITORY[:TAG]]

List images

Options:
  -a, --all             Show all images (default hides intermediate images)
      --digests         Show digests
  -f, --filter value    Filter output based on conditions provided (default [])
      --format string   Pretty-print images using a Go template
      --help            Print usage
      --no-trunc        Don't truncate output
  -q, --quiet           Only show numeric IDs

Solutions

Remove containers

  • Delete all containers:

    docker ps -q -a | xargs docker rm
    docker rm $(docker ps -a -q)
    
  • Remove all stopped containers:

    docker ps -q -f status=exited | xargs --no-run-if-empty docker rm
    

Remove images

  • Delete all untagged images (see Gist):

    docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
    
  • Remove dangling images:

    docker rmi $(docker images -q -f       dangling=true)
    docker rmi $(docker images -q --filter dangling=true)
    docker images -q -f dangling=true | xargs --no-run-if-empty docker rmi
    
  • Remove all images:

    docker images -q | xargs docker rmi
    docker images -q | xargs docker rmi -f
    docker rmi $(docker images -q)
    

Remove in 1.13.x

As of 1.13.0, see the new prune commands:

docker container prune # Remove all stopped containers
docker volume prune # Remove all unused volumes
docker image prune # Remove unused images
docker system prune # All of the above, in this order: containers, volumes, images

Bonus:

docker system df # Show docker disk usage, including space reclaimable by pruning

Comments

comments powered by Disqus

Previous topic

About Discourse

Next topic

TYPO3 Server Team Sprint

Tags

Archives

Languages

Recent Posts

This Page