docker

Table of Contents

main

Overview

Currently latest version is 17.12.0-ce.

Docker image and container command line interface

Introduction

is a client for interacting with the daemon (see dockerd(8)) through the CLI.

The Docker CLI has over 30 commands. The commands are listed below and each has its own man page which explain usage and arguments.

To see the man page for a command run man docker <command>.

How to Install

Install

Ubuntu 16.04 ~

# Remove old version
$ sudo apt-get remove docker docker-engine docker.io

# Install packages
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

# Add Docker's official GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

$ sudo apt-key fingerprint 0EBFCD88
  • x86_64 / amd64
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  • armhf
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  • IBM Power
$ sudo add-apt-repository \
   "deb [arch=ppc64el] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  • IBM Z (s390x)
$ sudo add-apt-repository \
   "deb [arch=s390x] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
$ sudo apt-get install docker-ce

Fedora

$ yum update
$ yum install docker
$ systemctl enable docker.service
$ systemctl start docker.service
$ systemctl status docker.service

Redhat

$ subscription-manager register –username=<username> –auto-attach
$ subscription-manager repos –enable=rhel-7-server-extras-rpms
$ subscription-manager repos –enable=rhel-7-server-optimal-rpms
$ yum update
$ reboot
$ yum install docker
$ systemctl start docker.service
$ systemctl enable docker.service
$ systemctl status docker.service

Installed Packages

Check

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:083de497cff944f969d8499ab94f07134c50bcf5e6b9559b27182d3fa80ce3f7
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/
$ sudo docker --version
Docker version 17.12.0-ce, build c97c6d6

Usage

Syntax

docker [OPTIONS] COMMAND [ARG...]

docker [ --help | -v | --version ]

Options

  • --config string :

Location of client config files (default "root.docker")

  • -D, --debug :

Enable debug mode

  • --help :

Print usage

  • -H, --host value :

Daemon socket(s) to connect to (default [])

  • -l, --log-level string :

Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")

  • --tls :

Use TLS; implied by --tlsverify

  • --tlscacert string :

Trust certs signed only by this CA (default "root.docker/ca.pem")

  • --tlscert string :

Path to TLS certificate file (default "root.docker/cert.pem")

  • --tlskey string :

Path to TLS key file (default "root.docker/key.pem")

  • --tlsverify :

Use TLS and verify the remote

  • -v, --version :

Print version information and quit

Variables

  • DOCKER_API_VERSION :

The API version to use (e.g. 1.19)

  • DOCKER_CONFIG :

The location of your client configuration files.

  • DOCKER_CERT_PATH :

The location of your authentication keys.

  • DOCKER_DRIVER :

The graph driver to use.

  • DOCKER_HOST :

Daemon socket to connect to.

  • DOCKER_NOWARN_KERNEL_VERSION :

Prevent warnings that your Linux kernel is unsuitable for Docker.

  • DOCKER_RAMDISK :

If set this will disable ‘pivot_root’.

  • DOCKER_TLS_VERIFY :

When set Docker uses TLS and verifies the remote.

  • DOCKER_CONTENT_TRUST :

When set Docker uses notary to sign and verify images. Equates to --disable-content-trust=false for build, create, pull, push, run.

  • DOCKER_CONTENT_TRUST_SERVER :

The URL of the Notary server to use. This defaults to the same URL as the registry.

  • DOCKER_HIDE_LEGACY_COMMANDS :

When set, Docker hides “legacy” top-level commands (such as docker rm, and docker pull) in docker help output, and only Management commands per object-type (e.g., docker container) are printed. This may become the default in a future release, at which point this environment-variable is removed.

  • DOCKER_TMPDIR :

Location for temporary Docker files.

  • HTTP_PROXY
  • HTTPS_PROXY
  • NO_PROXY

Commands

Command Description
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
checkpoint Manage checkpoints
commit Create a new image from a container’s changes
config Manage Docker configs
container Manage containers
cp Copy files/folders between a container and the local filesystem
create Create a new container
deploy Deploy a new stack or update an existing stack
diff Inspect changes to files or directories 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
image Manage images
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 Docker objects
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 networks
node Manage Swarm nodes
pause Pause all processes within one or more containers
plugin Manage plugins
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 one or more containers
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
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
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 Swarm
system Manage Docker
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
trust Manage trust on Docker images (experimental)
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 volumes
wait Block until one or more containers stop, then print their exit codes

References

Date: 2018-02-20

Author: Dongsoo Lee

Created: 2018-12-10 Mon 03:07

Validate