Docker - Hands-on

Cerulean CloudCerulean Cloud
2 min read

Before going ahead with installing and playing around with Docker, letโ€™s have a quick recap of the significant differences between Virtual Machines and Containers.

Virtual Machines

Virtual Machines emulate an entire computer, including its own operating system, on top of a physical server. They run on a hypervisor, which allows multiple VMs to operate on the same physical machine.

Containers

Containers are lightweight, standalone units of software that include everything an application needs to run: code, libraries, dependencies, and configuration files. They share the host operating system's kernel, making them highly efficient and fast to start.

Docker

Docker is one of the most popular container runtimes, making it simple to create, deploy, and run applications in containers.

Hereโ€™s a step-by-step guide to install Docker on Ubuntu and test it with a container.

Ensure your system is up-to-date before installing Docker.

sudo apt update
sudo apt upgrade -y

Docker requires certain prerequisites. Install them using the following commands:

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

Add the Docker GPG key to verify its packages:

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

Add the Docker repository to your system:

echo "deb [arch=$(dpkg --print-architecture) 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

Update the APT package index and install Docker:4

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

Ensure Docker is installed correctly:

sudo docker --version

Run the hello-world container to test your Docker installation:

sudo docker run hello-world

To run Docker without sudo, add your user to the Docker group:

sudo usermod -aG docker $USER

Then, log out and back in for the changes to take effect.

Understanding the distinction between containers and virtual machines can help you choose the right technology. While containers are ideal for lightweight, cloud-native applications, virtual machines provide robust isolation and flexibility for diverse workloads.

0
Subscribe to my newsletter

Read articles from Cerulean Cloud directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Cerulean Cloud
Cerulean Cloud

Cloud | AWS | DevOps | AI ๐Ÿ“ Toronto ๐Ÿ‡จ๐Ÿ‡ฆ ๐Ÿš€ Cloud Architect @ AWS ๐Ÿ‘จ๐Ÿฝโ€๐Ÿซ Professor