Docker containers

Installation

Complete the following steps to install the latest version of Docker under TPVM.
  1. Install and export the missing Gnu Privacy Guard (GPG) key.

    gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 1397BC53640DB551
    gpg --export --armor 1397BC53640DB551 | apt-key add -
  2. Add [arch=amd64] before http://d1.google.com/linux/chrome/deb/ stable main In the /etc/apt/sources.list.d/google-chrome.list file.

  3. Update the repository: apt-get -y update

  4. Install the CA certificates: apt-get -y install apt-transport-https ca-certificates

  5. Add the new GPG key for Docker: apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

  6. Create or update the /etc/apt/sources.list.d/docker.list file to contain the following string: deb https://apt.dockerproject.org/repo ubuntu-trusty main

  7. Update the Advance Packaging Tool (APT) package index: apt-get -y update

  8. Purge the old repository: apt-get -y purge lxc-docker

  9. Verify that APT is pulling the Docker engine from the proper repository: apt-cache policy docker-engine

  10. Install the Docker engine: apt-get -y install docker-engine

  11. Start Docker service: service docker start

  12. Verify the Docker installation by running the "hello-world" image: docker run hello-world

Docker Linux binaries can also be obtained from the following URL by means of the wget command:

After downloading the binaries, you extract the archive by using the tar -xvzf docker-latest.tgz command, which puts the binaries in a directory named /docker in the current location.

Depending upon the Docker engine version, you may have to set "execute" permission on the Docker daemon, by using the chmod +x docker command.

Docker requires the binaries to be installed in your host's $PATH. For example, you can move these binaries to /usr/bin.

Starting Docker

Start Docker by using theservice docker start & command.

The docker daemon always runs as the root user, and binds to a UNIX socket instead of to a TCP port. By default, that UNIX socket is owned by the user "root", and therefore is accessible by means of the sudo or root commands.

If you (or your Docker installer) create a UNIX group called "docker" and add users to it, then the docker daemon makes the ownership of the UNIX socket read/writable by the docker group when the daemon starts. The docker daemon must always run as the root user, but if you run the docker client as a user in the docker group, then you do not need to add sudo to all the client commands.

Upgrading Docker

To upgrade your manual installation of Docker, first kill the docker daemon by using the killall docker command.

Running and monitoring Docker containers

You can start, stop, and monitor Docker containers by using the docker command. The following table lists frequently used commands.
Table 1. Frequently used docker commands
Command Description
docker help Lists supported Docker commands
docker --version Displays the Docker version
docker create image Creates a new container
docker run -i -t ubuntu /bin/bash Instantiates a Docker container with bash shell and console connection
docker ps -a List all Docker containers
docker attach container-id Attach to a running Docker container
docker start container-id Start/restart a particular Docker container
docker stop container-id Stop a particular Docker container
docker rm $(docker ps -a -q Delete all Docker containers
docker rmi $(docker images -q Delete all Docker images