RobeeDS Logo

robeeds

Homelabbing

Getting to Know Docker for Homelabbing

Author

robeeds

Date Published

Introduction

For any person getting into homelabbing, it's a necessity to learn Docker. Docker, in its most basic form, allows developers to create containers—isolated instances of software capable of running applications. Docker allows its users to isolate services and prevent dependency issues between those services.

In other words, if two applications have different software requirements (ex. software 1 requires Python 2.7, while software 2 requires Python 3.12), each application can run its own environment without affecting the other. Considering this, Docker also provides its users with the sense of security and stability—if one service becomes faulty or compromised, it wouldn't affect the rest of the system drastically.


Installing Docker On Ubuntu Server

Having previously installed Ubuntu Server on a Raspberry Pi, we will now move forward with installing Docker.

Establishing an SSH connection to the server, we will run the following command to update our software repositories.

1sudo apt update

Now, install the default Docker package.

1sudo apt install docker.io

Enter 'Y' to install the necessary packages to support Docker's Installation

After Docker's installation is complete, go ahead and reboot the server

1sudo reboot


Managing Docker as a Non-Root User (Optional)

Reference

If you want to avoid having to enter your password each time you use a docker command, you can do the following.

1. Create a docker user group

1sudo groupadd docker

2. Add yourself to the docker group

1sudo usermod -aG docker $USER

3. Log out, then log back in

1exit
2ssh YOUR_USERNAME@IP_ADDR

4. Verify that Docker is functional with current privileges

1docker run hello-world


Docker Images vs Containers

Images: the template of instructions used to run a container

Container: the actual running process of an application


Basic Docker Commands and Usage

Listing Images

1docker image ls

Listing Containers

1# List active containers
2docker ps
3# List all containers
4docker ps -a

Pulling an image

1docker pull image_name:version

Running an image

1docker run image_name

Starting a Container

1docker start container

Restarting a container

1docker restart container_id

Stopping a container

1docker stop container_id

Removing an image

1docker rmi image_id

Removing a container

1docker rm container_id


Homelabbing

A few years ago I was gifted the Raspberry Pi 3B+ for Christmas. I made a few projects with it but never really documented what I did, and now...

Homelabbing,  Linux

As part of the homelabbing series, we'll be going over setting up a beginner-friendly homelab by first installing the operating system—that...