<img alt="" src="https://secure.leadforensics.com/150446.png " style="display:none;">

Install Docker on AWS EC2 (Ubuntu 16.04)

Amit Tidke Nov 14, 2018

Docker Docker Tutorial EC2 Ubuntu Ubuntu 16.04

Docker is a program that can implement a virtualization on your machine and you can pull any image of Operating System and launch that very light weight image on your machine. And you can create and run several operating systems in your single host machine. We can call these launched images as docker containers. Multiple containers will help us in decoupling the application dependencies. For example, we can have Web Server, Application Server & Databases in separate containers.

Here’s how:

Step 1: We have to create a separate user for docker. So add a new user using this command:
adduser docker

Step 2: Add this user to the Sudoers Group

Step 3: Add the the line “root ALL=(ALL:ALL) ALL ”:
docker ALL=(ALL:ALL) ALL

Step 4: Switch to docker user

sudo su docker

Step 5: Add GPG key for the official docker repository

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

Step 6: Add the docker repository and update the package

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

sudo apt-get update

Let’s check if we have configured the docker repository properly.

apt-cache policy docker-ce

The output should display that we are using docker-ce.

Docker Installation:

Installation command:

sudo apt-get install -y docker-ce

This command will install the docker and will start the docker daemon.
To check if this process is configured to start on boot:

sudo systemctl status docker

Executing Docker commands without sudo:

This part is optional but if you rather not use “sudo” with each command then you should have a look at this part of blog.

We have to add the username to the docker group

sudo usermod -aG docker ${USER}

To apply this change, either we have to logout & login again or make use of the following command.

su - ${USER}

This will ask for a password and now you can check if you have added this user to the group or not.

id –nG

Test the Docker

Once you have checked off the above steps relating to docker installation, we would need to check if our machine could access the Docker hub. This will download and run the hello-world program.

docker run hello-world

This should display the output as

"Hello from Docker!

This message shows that your installation appears to be working correctly."

This confirms that we have successfully installed and configured the docker on our machine. You are now ready to explore many awesome things with the Docker!

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.