Exercise: Install Docker Engine on Ubuntu Computer


Description: In this exercise, you will install the Docker Engine on an Ubuntu system. Docker is an open-source platform that enables developers to automate the deployment, scaling, and management of applications inside lightweight, portable containers. By installing Docker, you will be able to create, deploy, and manage containers on your system.

Difficulty Level

Beginner

Estimated Duration

0:30:00

Prerequisites

No prerequisites have been identified for this exercise.

Resources

  • Computer: A desktop or laptop computer used by developers for writing, compiling, testing, and debugging code. It runs IDEs and supports various programming languages.
  • Monitor: Visual output devices for displaying information, data, or images, including LED, LCD, and OLED screens.

Install Docker Engine on Ubuntu Computer

Introduction

In this exercise, you will install the Docker Engine on an Ubuntu system. Docker is an open-source platform that allows you to automate the deployment, scaling, and management of applications within lightweight, portable containers. By the end of this exercise, you will have Docker installed on your Ubuntu system, enabling you to run and manage containers for application development and testing.

Objectives

By completing this exercise, you will:

  • Learn how to install Docker Engine on an Ubuntu computer.
  • Understand the basics of Docker and containerization.
  • Gain hands-on experience in setting up and using Docker to manage containers on your system.

Materials

You will need the following supplies to complete the exercise:

  • A computer running Ubuntu 18.04 or later.
  • An active internet connection.
  • Access to the terminal or command line interface.

Preparation Steps

  1. Ensure your Ubuntu system is updated:
    • Open a terminal window.
    • Run the following command to update your system's package index:
      sudo apt update
      
  2. Install necessary dependencies to allow apt to use packages over HTTPS:
    • Run the following command:
      sudo apt install apt-transport-https ca-certificates curl software-properties-common
      

Execution Steps

Follow these steps to install Docker Engine on your Ubuntu system:

  1. Add Docker's official GPG key:

    • Run the following command to add Docker's GPG key:
      curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
      
  2. Set up the Docker stable repository:

    • Add the Docker repository to your APT sources:
      sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
      
  3. Update the package index again:

    • Run the following command to refresh the package list with the new Docker repository:
      sudo apt update
      
  4. Install Docker Engine:

    • To install the latest version of Docker Engine, run:
      sudo apt install docker-ce
      
  5. Verify Docker Installation:

    • After installation, check if Docker is running by executing:
      sudo systemctl status docker
      
    • You should see a message indicating that Docker is active and running.
  6. Run Docker without sudo (Optional):

    • To avoid needing sudo with Docker commands, add your user to the Docker group:
      sudo usermod -aG docker $USER
      
    • Log out and log back in for the changes to take effect.
  7. Test Docker:

    • Run the following command to test if Docker is working properly:
      docker --version
      

Further Reading

To deepen your understanding of Docker and containerization, you may explore the following resources: