Skip to content

How to Easily Install Docker on Ubuntu 22.04

Advertisement

Docker is a popular tool that allows you to create, deploy, and run applications in containers. Containers package an application with all its dependencies, making it easy to run on any system. This guide will walk you through installing Docker on Ubuntu 22.04 and running your first container. We will cover the basic commands you need to start using Docker effectively. By the end of this tutorial, you will have a working Docker setup and a basic understanding of how to use it.

Step 1: Update Your System

Before installing Docker, it is important to update your system. Open your terminal and type:

sudo apt update
sudo apt upgrade

This will update your package lists and install any available upgrades.

Step 2: Install Docker

To install Docker, you need to add the Docker repository to your system. Run the following commands in your terminal:

  1. Install required packqages:
    sudo apt install apt-transport-https ca-certificates curl software-properties-common
    
  2. Configure GPG key:
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
    
  3. Setup Docker PPA:
    echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    
  4. Update packages cache:
    sudo apt update
    
  5. Install Docker engine:
    sudo apt install docker-ce
    

Step 3: Start and Enable Docker

After installing Docker, you need to start the Docker service and enable it to start on boot. Use these commands:

sudo systemctl start docker
sudo systemctl enable docker

Step 4: Verify Docker Installation

To check if Docker is installed correctly, run:

sudo docker --version

This command will display the installed Docker version.

Step 5: Running Your First Docker Container

Now that Docker is installed, let’s run a simple Docker container. Type the following command to run a test container:

sudo docker run hello-world

This command downloads and runs a simple Docker container that prints “Hello from Docker!”

Step 6: Using Docker Commands

Here are some basic Docker commands to help you get started:

  • List Docker images: sudo docker images
  • List running containers: sudo docker ps
  • List all containers: sudo docker ps -a
  • Stop a running container: sudo docker stop CONTAINER_ID
  • Remove a container: sudo docker rm CONTAINER_ID
  • Remove an image: sudo docker rmi IMAGE_ID

Conclusion

Congratulations! You have successfully installed Docker on Ubuntu 22.04 and run your first Docker container. Docker is a powerful tool that can simplify the process of managing and deploying applications. Keep exploring Docker commands and containers to become more comfortable with this tool. Happy Dockerizing!

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top