Monday, 31 December 2018

How to install and setup Docker on Ubuntu ?


Prerequisites
  • Ubuntu version must be > 32 bit install
  • Ubuntu kernel version must be > 3.10
    • Check with command : $ uname -r
  • Update the kernel : sudo apt-get update

Install
  • Ensure wget is installed with command : $ which wget
  • Download and install docker using wget
    $ wget -q0- https://get.docker.com/ | sh
    Wait to complete the processing
Verify Docker deamon
  • Run command : $ sudo docker run hello-world
    A result from this command ("Hello from Docker") shows docker is installed and ready to use.

CREATE DOCKER GROUP
Docker deamon runs by default on a TCP port and owned by root user.
Normally, we must create a docker group and associate other docker users.

Run command : $ sudo usermod -aG docker user1
which will create group "docker" and update access to user "user1"
Login with user1, and you can run docker commands without "sudo"$ docker run hello-world


ADJUST MEMORY
To gain performance with docker, edit the grub file (having sensitive info) and restart kernel.
$ vim /etc/default/grub
Update property : GRUB_CMDLINE_LINUX="cgroup_enabled=memory swapaccount=1"
Save and exit the terminal.

Update grub file with command : $ sudo update-grub


ENABLE UNCOMPLICATED FIREWALLS (UFW)
UFW by default drops all the forwarding traffic, which could impact networking between multiple docker containers.


Verify UFW status (by default, inactive) : $ sudo ufw status

Edit ufw configuration : $ sudo vi /etc/default/ufw

Update property : DEFAULT_FORWARDING_POLICY="ACCEPT"
Reload the configuration : $ sudo ufw reload

Configure incoming connections on specific port (2375) : $ sudo ufw allow 2375/tcp

Check again ufw configuration : $ sudo vi /etc/default/ufw

Property must be as we have set : DEFAULT_FORWARDING_POLICY="ACCEPT"

CONFIGURE DNS IP ADDRESS
By default, DNS is 127.0.0.1 and localhost
Edit docker file : $ sudo vi /etc/default/docker

Update and save property : DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"


Restart Docker deamon : $ sudo restart docker


No comments:

Post a Comment

Note: only a member of this blog may post a comment.