For now we installed docker on RHEL /CentOS. Here will see how to install on famous developer’s favorite OS “Ubuntu”. He has some interesting steps to install a docker like add some supporting packages and add docker key (quiet same as RHEL/Centos) and Add docker repository to Apt sources
# apt-get update
# apt-get -y upgrade
Make sure aufs support is available
# apt-get install linux-image-extra-`uname -r`
Add docker repository key to apt-key for package verification
# apt-key adv –keyserver hkp://pgp.mit.edu:80 –recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Add the docker repository to apt sources, it varies each version of Ubuntu, select the correct one while you install
The possible entries are:
- On Ubuntu Precise 12.04 (LTS)
- deb https://apt.dockerproject.org/repo ubuntu-precise main
- On Ubuntu Trusty 14.04 (LTS)
- deb https://apt.dockerproject.org/repo ubuntu-trusty main
- Ubuntu Wily 15.10
- deb https://apt.dockerproject.org/repo ubuntu-wily main
- Ubuntu Xenial 16.04 (LTS)
deb https://apt.dockerproject.org/repo ubuntu-xenial main
Once you confirm you OS version add APT resources details as below,
# echo “deb https://apt.dockerproject.org/repo ubuntu-xenial main ” | sudo tee /etc/apt/sources.list.d/docker.list
Update the repository with the new addition
# apt-get update
Finally, download and install docker:
# apt-get install docker-engine
Enable UFW forwarding
If you use UFW (Uncomplicated Firewall) on the same host as you run Docker, you’ll need to do additional configuration. Docker uses a bridge to manage container networking. By default, UFW drops all forwarding traffic. As a result, for Docker to run when UFW is enabled, you must set UFW’s forwarding policy appropriately.
Also, UFW’s default set of rules denies all incoming traffic. If you want to reach your containers from another host allow incoming connections on the Docker port. The Docker port defaults to 2376 if TLS is enabled or 2375 when it is not. If TLS is not enabled, communication is unencrypted. By default, Docker runs without TLS enabled.
To configure UFW and allow incoming connections on the Docker port:
Login to Ubuntu as a Root user
Make sure UFW is installed and enabled.
# ufw status
Open the /etc/default/ufw file for editing.
# vim /etc/default/ufw
Set the DEFAULT_FORWARD_POLICY policy to:
DEFAULT_FORWARD_POLICY=”ACCEPT”
Once you enable save and close the file and reload the UFW
# ufw reload
Allow incoming connections on the Docker port.
# ufw allow 2375/tcp