Docker 101 – Installation Of Docker

We are going to introduce Docker in this post. Our goal in the Docker series will be to first demonstrate installation of Docker, configuration of the Docker hub, Docker images, and the Docker file to show how to create your own images.

We are going to be installing the Docker image on an AWS EC2 instance in this post. The steps shown will be focused on the command line but will have some theory added between steps to help with understanding what we are doing.

The first step we recommend is verifying the operating system (OS) you will be installing Docker on. Each OS will have a different command. For an AWS EC2 instance we use cat /etc/os-release.

The next step will be to update our installed packages and package cache for our OS. We do this on an AWS instance with sudo yum update -y.

We will install Docker once the updates finish with the sudo amazon-linux-extras install docker command. Your command will be different if you are not using an AWS EC2 instance.

Our next step will be to start the Docker service with the sudo service docker start command.

In AWS we will now need to add the ec2-user to the docker group to allow execution of Docker commands without sudo.

sudo user mod -a -G docker ec2-user

At this point we will log out of our SSH session and then log back in to make sure that our new docker group permissions are picked up. We will need to verify that the user is able to run Docker commands with sudo.

If the docker info command does not execute properly you will need to reboot your system. In some cases this is required for a user to access the Docker daemon but in most cases simply exiting the SSH session will be sufficient.

We have just installed Docker and then started the Docker service. Let’s start our first container.

The container was pulled from the Docker library since we are using a new Docker installation. It is a small image used to confirm that the installation completed correctly. If the container is pulled without generating an error we know that the Docker client is able to communicate with the Docker daemon which the was able to pull the image from the Docker hub. The Docker daemon was then able to create a new Docker container from the image which produce the image shown in above screenshot.

Thank you for joining us in this post. We will discuss the Docker Hub in our next post. Please consider following our blog to ensure you are updated when new posts our uploaded to the library.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.