👍

Cheap Home LAN Playground Using Docker - s1/7

2022/12/03に公開

*日本語でもご覧ください
Series Top: Dockerで作るおうちLAN遊び場

Introduction

I would like to post a blog series on my home LAN playground that runs various services using Docker. The intended audience is someone interested in trying out Docker to test out different services, GitLab (GitLab Runner and GitLab Pages as well), and someone who wants to do scripting and programming using these services.

You can try many of the things covered in this blog series using less than 20k JPY mini fanless PC. My first machine has 4G memory. My second machine running GitLab has 16G memory as it is a bit more demanding, but 8G memory should be enough for you if you are going to run just the services covered in this series.

What I really have is my paid public DNS domain name and TLS certificate signed by a public CA, but in this series I will just use a private domain, private CA, and self-signed certificate so that you can follow the steps without purchasing your own DNS domain.

End-state Illustration

Here is the illustration of what I will have at the end of this series. All of the services illustrated here will be running as Docker containers.

Docker Containers

Here is the list of services I will cover, and I will list the docker image names actually used in each blog entry.

  • DNS
  • Jupyter Notebook
  • GitLab
  • GitLab Runner
  • Nginx
  • Authelia

Machine Setup

Preparing a machine (or two if creating a complete mirror) with docker and docker compose installed should be fine to follow procedures explained in the following posts. Just to share my environment, I use Debian starting with minimal install, ssh server enabled, and no desktop service, running in headless, and here are some generic settings I configured.

sudo

I think Ubuntu has sudo setup for the initial user created. In case with Debian, I have to manually install and setup for my usual user ID.

su -
apt install sudo
gpasswd -a {your username} sudo

IP Address

I configure static IP address for this machine by editing the configuration file, sudo vi /etc/network/interfaces. In this example, the interface name is enp2s0, IP address for this machine is 192.168.1.56, and the network gateway is 192.168.1.1.

# The primary network interface
allow-hotplug enp2s0
#iface enp2s0 inet dhcp
iface enp2s0 inet static
address 192.168.1.56
netmask 255.255.255.0
gateway 192.168.1.1

DNS

Edit DNS configuration file (sudo vi /etc/resolv.conf) to configure which DNS server to use. I will be setting up DNS server using Docker later. Until that's available, I can configure the nameserver to be something that my ISP is providing, or something Cloudflare or Google is providing, 1.1.1.1 or 8.8.8.8.

options rotate
nameserver 1.1.1.1
nameserver 8.8.8.8

Docker

The procedure to install Docker is available in the official document. The one I'm refering here is for Debian but the documentation for other OS is also available in the official document.

https://docs.docker.com/engine/install/debian/

https://docs.docker.com/compose/install/

Install requirements.

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

Add gpg key.

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

Set "stable" package to use.

echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install docker and add user to the docker group.

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo groupadd docker
sudo usermod -aG docker $USER

Closing

And this is it for the first post. In the next post, I will be running DNS server and Jupyter Notebook using Docker.

next: DNS and Jupyter Notebook Using Docker

Discussion