Setup Docker Engine on Ubuntu Desktop
Easy guide on running docker for your first app.
Introduction
Today, I'm going to write about how I started using Docker on my old machine (now working as my personal playground). If you haven't yet read the article, feel free to read it here (How I Turned My Old Laptop into a Ubuntu Server). Docker is really important for developers to learn and it can be hard for beginners to learn especially if doesn't get exposed with this tool. End up you might struggle learning this alone including me. I also just learn all of these from connecting and learning from those that are already in the industries. Let's start simple by installing it first in your machine.
Downloading and Installing Docker.
In here, I'll show on how to download and install Docker Engine on Ubuntu Desktop. If you're on Windows, you can just download Docker Desktop Installer on their page here and choose the installer for Windows. Linux also have Docker Desktop but in my case, I wanted only the Docker Engine for my learning experience and production-like experience because most of the time you'll be interacting with servers without the GUI. I also wanted to self-host some of my side project application.
Initial docker setup.
Setting up docker is actually quite simple. You just need to read the documentation here. The link will bring you to the installation documentation for Docker Engine on Ubuntu. There's multiple ways to install docker into your machine. One of the way that I'll write about here is on how to set up and install Docker Engine from Docker's apt directory. `apt` stands for Advanced Package Tool for Linux related OS. It is similar to how PIP works in Python if you're a Pythonista. So, we need to install Docker directory into the `apt` directory for better dependency management instead of installing manually. Now, let's go through step-by-step.
- First step is to make sure that you have already remove or uninstall any conflicting package that you have install previously intentionally or unintentionally. If you're installing this the first time, you can skip this step.
-
Open up your terminal, and run below code:
*sudo is a root/administrator command. It will prompt a password for the root access.# Add Docker's official GPG key: sudo apt-get update sudo apt-get install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc # Add the repository to Apt sources: echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update
Your terminal will look like this and you just need to agree to the prompt [press y] -
Once the process is finish, your docker directory are already install in `apt` directory. Then, you can run this command:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
-
Finally, to test if you successfully install docker engine into your machine, you can run
It will download a test image, build the container and run the container in one go. If you're successfully install docker engine in your machine, you will get this prompt in your terminalsudo docker run hello-world
Contact me
If you have any questions or would like to get in touch (I'm also open to learn from you guys too!), feel free to reach out to me through email.