Getting Started with Docker on Ubuntu in 5 minutes

Getting Started with Docker on Ubuntu in 5 minutes

Docker is a powerful platform for automating the deployment and scaling of applications in lightweight, portable containers. If you’re new to Docker and using Ubuntu as your operating system, this guide will walk you through the steps to set up Docker and start working with containers.

Prerequisites

Before you begin, ensure that you have access to a machine running Ubuntu. You’ll also need administrative privileges to install Docker and manage containers.

Step 1: Update Package List

Open a terminal and update the package list to make sure you’re getting the latest versions of the software.

sudo apt update

Step 2: Install Docker Dependencies

Install the necessary packages that allow the system to use repositories over HTTPS.

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

Step 3: Add Docker GPG Key

Add Docker’s GPG key to verify the integrity of the packages.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Step 4: Set Up Docker Repository

Add the Docker stable repository to your system.

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

Step 5: Install Docker Engine

Update the package list and install Docker.

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

Step 6: Verify Docker Installation

Ensure Docker is installed correctly by checking the version.

sudo docker --version

Step 7: Manage Docker as a Non-root User (Optional)

To run Docker commands without sudo, add your user to the docker group.

sudo usermod -aG docker $USER

Step 8: Verify Docker without Sudo

Run a test container to verify that Docker is working without sudo.

docker run hello-world

Congratulations! You’ve successfully set up Docker on Ubuntu. You’re now ready to explore the world of containers and build, ship, and run applications with ease.

Conclusion

Docker simplifies the process of packaging and distributing applications, making it an essential tool for developers and system administrators. This guide has provided you with the steps to set up Docker on Ubuntu, opening the door to a more efficient and portable development environment. Now, you can start creating, deploying, and managing containers with confidence. Happy coding!

Leave a Reply

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