Docker

Table of Contents

Overview

Reference

Dockerfile

LABEL

LABEL <key>=<value> <key>=<value> <key>=<value> ...
LABEL "com.example.vendor"="ACME Incorporated"
LABEL com.example.label-with-value="foo"
LABEL version="1.0"
LABEL description="This text illustrates \
that label-values can span multiple lines."
LABEL multi.label1="value1" multi.label2="value2" other="value3"
LABEL multi.label1="value1" \
      multi.label2="value2" \
      other="value3"

MAINTAINER (deprecated)

LABEL maintainer="SvenDowideit@home.org.au"

RUN

RUN apt-get update && apt-get install -y \
    aufs-tools \
    automake \
    build-essential \
    curl \
    dpkg-sig \
    libcap-dev \
    libsqlite3-dev \ mercurial \
    reprepro \
    ruby1.9.1 \
    ruby1.9.1-dev \
    s3cmd=1.1.* \
 && rm -rf /var/lib/apt/lists/*

CMD

COPY

COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt
COPY . /tmp/

Terminology

Topics

Dockerfile: ADD vs COPY

How-to

Install docker with a single command

curl -sSL https://get.docker.com/ | sh

Install docker on Amazon Linux instance

sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user

Access internet from containers when private DNS intrudes

In private network with private DNS, the network administrator often blocks access to common DNS like 8.8.8.8. This may cause to block access to internet within the docker container.

In this case, the private DNS is used within docker containers with --dns option. To use this option by default, put the following line in /etc/default/docker:

# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="--dns 10.10.0.1 --dns 10.10.0.2"

Additionally, systemd script for docker doesn't read /etc/default/docker and $DOCKER_OPTS. To fix it, add following lines to /lib/systemd/system/docker.service:

[Service]
// ...
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS

Links