Installing Docker and creating Docker image in Ubuntu [AWS EC2]

This article demonstrates installing and using Docker on AWS UBUNTU server. 

Installing Docker

The Docker installation package available in the official Ubuntu 16.04 repository may not be the latest version. To get the latest and greatest version, install Docker from the official Docker repository. 
This section shows you how to do just that.
1. First, add the GPG key for the official Docker repository to the system:


2. Add the Docker repository to APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu
$(lsb_release -cs) stable"
3. Installing docker and related packages
 update the package database with the Docker packages from the newly added repo:
$sudo apt-get update
Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
$apt-cache policy docker-ce 

Install Docker: 
$sudo apt-get install -y docker-ce 
Start Docker Service: 
$sudo systemctl status docker 

4. Check Docker Info: 
$ sudo docker info

5. List Docker Images:
$ docker images 

6. Now let's try to create custom docker image: Create a folder and create DockerFIle inside that. 

7. Add content to Dockerfile as follows: 

8. Build your own Docker container: 


Step 9: In order to create an image over the existing container, first sign up to Docker Hub which is similar to GitHub. 
Link: https://hub.docker.com 
Step 10: Now login to docker hub from the server: 

Step 11: List down available docker images on your local server:

Step 12: tag your docker image: 

Step 13: Push the image to your docker hub:

Step 14: Now the image will be available on your Docker Hub a/c. 

Similarly, you can try with other services like MySQL, Apache, LAMP etc.  

Comments