(Updated March 2016)
See newer notes at https://paulgorman.org/technical/docker.txt.
Docker is a container system that traditionally provides single-process, non-persistent containers (though data persistence is possible with Docker Volumes). Docker has become popular for packaging and distributing software, particularly microservice components.
Docker has a Docker Server with containers as clients. The server and client are provided by the same binary. Optionally, a third component, the Docker Registry, stores Docker images and metadata.
A note about how file systems normally work in Docker: a normal Docker container has a read-only file system based on the Docker image from which it was created. Above this, the container has a read-write layer that stores differences from the read-only original image layer. However, when the container is destroyed, the changes in the read-write layer are discarded; future spin-ups of the Docker image start fresh with the original read-only layer. Docker calls this the Union file system.
Docker is part of the Debian package system (docker.io), but we want a more current version from Docker’s repository.
# apt-key adv \ --keyserver hkp://p80.pool.sks-keyservers.net:80 \ --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Create /etc/apt/sources.list.d/docker.list, and add one of these:
deb https://apt.dockerproject.org/repo debian-jessie main deb https://apt.dockerproject.org/repo debian-stretch main
(Note that apt-cacher-ng has a problem with this. Use https as an alternative. https://github.com/docker/docker/issues/9592)
# apt-get install apt-transport-https # apt-get update # apt-get purge 'lxc-docker*' 'docker.io*' # apt-get install docker-engine % docker --help
List docker containers:
# docker ps -a # docker images -a
A Dockerfile specifies how to build a container.
FROM fedora:23 MAINTAINER Paul Gorman RUN dnf update && dnf install asterisk && dnf clean all ADD ./sip.conf /etc/asterisk/ ADD ./extensions.conf /etc/asterisk/ EXPOSE 5060-5061/tcp EXPOSE 10000-20000/udp CMD ["/usr/sbin/asterisk"]
Assuming ‘Dockerfile’ is in our current directory, build the container with:
% docker build --tag "my_base_container" ./
# docker pull fedora # docker run -it fedora /bin/bash [root@2ab31fa5597a /]# dnf update [root@2ab31fa5597a /]# dnf install asterisk
Project Atomic is a light-weight Red Hat-based Docker supervisor OS.
CentOS has Atomic Host builds available as ISO for bare-metal install, Amazon AMI image, and QCOW2 image for KVM.
Before spinning up our first Atomic host, we need cloud-init in place to handle early initialization of the instance. cloud-init does things like: