This section addresses the installation and management of Docker containers.
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 -
Add [arch=amd64] before http://d1.google.com/linux/chrome/deb/ stable main In the /etc/apt/sources.list.d/google-chrome.list file.
Update the repository: apt-get -y update
Install the CA certificates: apt-get -y install apt-transport-https ca-certificates
Add the new GPG key for Docker: apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
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
Update the Advance Packaging Tool (APT) package index: apt-get -y update
Purge the old repository: apt-get -y purge lxc-docker
Verify that APT is pulling the Docker engine from the proper repository: apt-cache policy docker-engine
Install the Docker engine: apt-get -y install docker-engine
Start Docker service: service docker start
Verify the Docker installation by running the "hello-world" image: docker run hello-world
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.
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.
To upgrade your manual installation of Docker, first kill the docker daemon by using the killall docker command.
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 |