Install DOCKER on UBUNTU

How to Install Docker on Ubuntu

Step 1: Update Your System

Before installing Docker, it's a good practice to update your system to ensure you have the latest package information. Open a terminal and run the following commands:

sudo apt update
sudo apt upgrade -y

Step 2: Install Docker Dependencies

Docker requires some dependencies to be installed. You can install them using the following command:

sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

Step 3: Add Docker Repository

Add the Docker repository to your system using the following commands:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [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

Step 4: Install Docker Engine

Now, you can install Docker Engine on Ubuntu with the following commands:

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io

Step 5: Start and Enable Docker

Once Docker is installed, start the Docker service and enable it to start automatically on boot:

sudo systemctl start docker
sudo systemctl enable docker

Step 6: Verify Docker Installation

You can verify that Docker has been successfully installed by running the following command:

sudo docker --version

Step 7: Test Docker

To check if Docker is working correctly, you can run a simple Docker command to pull and run an example container:

sudo docker run hello-world

This command will download and run a "Hello World" Docker container. If everything is set up correctly, you will see a message confirming that your installation appears to be working correctly.

Step 8: Add Your User to the Docker Group (Optional)

By default, Docker commands require root privileges, which means you need to use sudo for every Docker command. To avoid this, you can add your user to the Docker group:

sudo usermod -aG docker $USER

After running this command, you'll need to log out and back in for the changes to take effect. Once added to the Docker group, you can run Docker commands without using sudo.

Step 9: Test Docker as a Regular User (Optional)

As a regular user (without using sudo), you can test Docker:

docker run hello-world

This should produce the same "Hello World" output as before.

That's it! You've successfully installed Docker on Ubuntu. You can now use Docker to run containers and manage containerized applications on your system.

Related Articles