PRACTICE WITH DOCKER
Tags: azure, beginners, devops, microservices
Published: 2022-11-12 23:13:29

****Introduction****
This article will help you through docker configuration, downloading and building a container image. 

****Prerequisites****
- You must have installed the VM ware Work Station Pro

- Downloaded and configured your Ubuntu Desktop. 

****STEP ONE: Pasting URL**** 

- Open your broswer and paste the URL:https://docs.docker.com/engine/install/ubuntu/
![Firefox Browser](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/djaqajzk5qm392i6wgyc.png)

- If copied correctly, you should be presented with the page as shown below. 
![Browser screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ki3jq4v1r3tx1a65otd.png)

****STEP TWO: Setting up Repository**** 

The next step is to set up the docker repository to enable you install and update docker from the repository.

- Copy and paste the following command on your terminal:
****sudo su**** 
The above command will require the password used in setting up the Ubuntu desktop. Once inputted, copy and paste the following commands accordingly: 
![command 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/deh2d24y847rf4zncekj.png)
Your screen should appear like this
![Setting up docker](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fgvc3fum0n4nnvzfmdx8.png)

- Next, copy and paste the paste the command to add Docker official GPG Key

![Command 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ed87fpklhh8oodsvn3zs.png)
![Adding Docker key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j0a1ftswwwb7ih068ifz.png)

- Then, set up the repository with the code below
![Command 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vnfz6liaht9jo4rk6nl4.png)
![Set up repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jnemjbtp1b3rok4zr5x6.png)

****STEP THREE:Install Docker Engine**** 

- First you will have to update the _apt_ package index with the command below

![Command 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gx6cujetvnl5hm660kpx.png)
![Update apt package index](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vxo4pbeq5ym1vos783dw.png)

- After sucessfully updating, we will go with installing the latest version of your docker engine. 
![Command 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/62if9r1iqzf615x9ck37.png)
![Install latest version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r41n4md32qbuzbe8iqj0.png)

- Next step is to verify the successful installation of your emgine by running the command below:
![Command 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n24fzvnfra1fvsdx44tu.png)
![Successful installation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vf3m9eyn9h6i0czyhouq.png)

****STEP FOUR: Download a Container Image****

- Go to ****https://hub.docker.com/****

- Click on Explore and search for Nginx

- On the left hand side of your screen, copy ****docker pull nginx**** 
![Nginx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wj518raipxj59cwbvuip.png)

- Paste the copied command in your terminal and hit enter to download the container image in your local environment. 
![Download Nginx in local environment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fo1qhmcrlmth8uwx1c8o.png)

****STEP FIVE: Start a Container Image**** 

- On your terminal, run the command ****docker run nginx --detach --publish-all nginx:latest****
![Run command](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ljcdc5kc932umudebvgr.png)

- Run ****docker ps**** to display the port number 
![Display Port](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9d6gq5wh14wpw9hx4km.png)

- Run ****ip addr show**** to get the ip address of your machine
![IP address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ax4gq57e2hzw4lduo7m8.png)

- Copy your IP address and port number. 


![IP address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oombvtqk7epnfdt7qo79.png)
![Port number](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x37swdoeckhkddc6xqee.png)

- Go to your browser and type: ****ip address:port**** You show see something like the picture below

![Welcome to nginx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bwrsvakx6wz6fy5gbabt.png)


****STEP SIX: Build a Container Image**** 

Follow the  following steps to build the specified image. 

- Create a directory and change to the directory created by running the following command. In this tutorial, our directory will be named ****cloud**** 
****mk dir cloud****
****cd cloud****
![Create Directory](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ica1inaarr5q0lhp1wi0.png)

- Create a linux text document called ****Dockerfile**** using the command ****vim Dockerfile****
If done correctly, your screen should appear like the one below

![Dockerfile](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j7xqlfk2pkahkimffjby.png)

- Paste the following into the text editor. N/B You can only input anything into the text editor by pressing your "I" button
****FROM**** ubuntu****
****MAINTAINER (your email address)****
****CMD ['echo', 'hello world']****
![Text editor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6vs1wjnwb13zafsvzht1.png)

- Press ****esc****, ****shift + :****, then type ****wq**** to save your text
![Save text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5uu5kbbwbb37km55lgds.png)
- Exit the text editor by pressing **enter**

- Build the container image using the following code 
****docker build -t (name of your choice) .****
![Build Container Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a7esrpkv0vsg4jks03od.png)