DEV Community

Cover image for PRACTICE WITH DOCKER
etidoekom
etidoekom

Posted on

PRACTICE WITH DOCKER

*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*

*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
    Your screen should appear like this
    Setting up docker

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

Command 2
Adding Docker key

  • Then, set up the repository with the code below Command 3 Set up repository

*STEP THREE:Install Docker Engine*

  • First you will have to update the apt package index with the command below

Command 1
Update apt package index

  • After sucessfully updating, we will go with installing the latest version of your docker engine.
    Command 2
    Install latest version

  • Next step is to verify the successful installation of your emgine by running the command below:
    Command 3
    Successful installation

*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

  • Paste the copied command in your terminal and hit enter to download the container image in your local environment.
    Download Nginx in local environment

*STEP FIVE: Start a Container Image*

  • On your terminal, run the command *docker run nginx --detach --publish-all nginx:latest*
    Run command

  • Run *docker ps* to display the port number
    Display Port

  • Run *ip addr show* to get the ip address of your machine
    IP address

  • Copy your IP address and port number.

IP address
Port number

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

Welcome to nginx

*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

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

Dockerfile

  • 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

  • Press *esc, *shift + :, then type **wq**** to save your text
    Save text

  • 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

Top comments (0)