Docker – Setup

I am drafting the step-by-steps to install Docker in this post.

VM Setup

I created a new Ubuntu VM 16.04 in my Xen Server with manual network setup. Hence I have given a static IP to this new VM.

I Installed the xentools using the following commands. This is not required if you do not want to install it.

[code language=”bash”]

sudo mount /dev/dvd /media
sudo /media/pandian/XenServer\ Tools/Linux/install.sh

[/code]

 

After successful installation of xentools, a reboot of VM is required.

Install SSH demon.

[code language=”bash”]

sudo apt update

sudo apt upgrade

sudo apt-get install openssh-server

sudo apt-get install curl

[/code]

 

Add the GPG of docker repository.

[code language=”bash”]

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –

[/code]

 

Add Docker repository to ubuntu sources and install Docker from docker repo, instead of default ubuntu repo.

[code language=”bash”]

sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

sudo apt-get update

apt-cache policy docker-ce

sudo apt-get install -y docker-ce

sudo systemctl status docker

[/code]

Docker is now installed and started.

But it needs sudo to run docker command.

[code language=”bash”]

$ docker info
Got permission denied while trying to connect to the Docker daemon socket at uniial unix /var/run/docker.sock: connect: permission denied
$ sudo docker info

[/code]

Hence, add the unix user to docker group to avoid it. Here is how we shall do it. Credit goes to digitalocean.

[code language=”bash”]

~$ sudo usermod -aG docker ${USER}
~$ su – ${USER}
Password:
~$ id -nG
pandian adm cdrom sudo dip plugdev lpadmin sambashare docker

$ id
uid=1000(pandian) gid=1000(pandian) groups=1000(pandian),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare),999(docker)

[/code]

So the user has been added to docker group. id confirms the same. Now it is the time to run our first hello-world container. As we do not have this image locally, it is downloaded from docker repository.

[code language=”bash”]

~$ docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
9db2ca6ccae0: Pull complete
Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

[/code]

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top