How to setup a website on your own PC with Docker

Blog IndexHome Page

What is Docker?

If you already know what Docker is, click here

Think of Docker as a lightweight virtual machine that you can run on system startup. There are a lot of images to choose from, some with specific purposes like to run a Web Server or to install a specific app.

Docker is great if you want to self host stuff without polluting your PC with config files, logs, etc

Installing Docker

On Debian/Ubuntu

sudo apt install docker

On Fedora 34

Follow this guide

On Arch/Manjaro

sudo pacman -S docker

Starting/Enabling Docker service

sudo systemctl enable --now docker.service

On Windows 10

Follow this guide

Installing and running a image

For this tutorial I will be using the official Debian image but you can choose another image here

You can pull the image using this command

docker pull debian

To run the image run this command. You can change the name to whatever you want, you can also change the ports but I don't recommend doing it

docker run -t -d -p 80:80 -p 443:443 --name website debian:latest

Installing packages inside the container

To run a bash shell inside the container run

docker exec -it website bash

Now let's install some packages

apt update && apt install nginx certbot python3-certbot python3-openssl openssl python3-certbot-nginx nano && service start nginx

Checking if it works

On your host machine open your browser and access localhost

If that doesn't work allow port 80 on your firewall and try again

Configuring nginx

The directory of the nginx website is probably /var/www/html and the config files are on /etc/nginx

Blog IndexHome Page

More information

If you need more information you can contact me