Installing Docker

I have become addicted to Docker, and I feel like I have just started using it. It’s like the fun of discovering open source software but for the whole home-lab. It’s like Christmas learning about all of these tools that I can power up with a single command. It’s time to make it official and put it on my main server.

First step was to setup the apt repository for Docker:

# Add Docker's official GPG key:
sudo apt update
sudo apt 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:
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
Architectures: amd64
EOF

sudo apt update

Note: at first, I tried without the “Architectures: amd64” line in the sources file. It failed trying to look for i386 packages. After adding that line, the update worked fine. This was the error:

N: Skipping acquire of configured file 'stable/binary-i386/Packages' as repository 'https://download.docker.com/linux/ubuntu jammy InRelease' doesn't support architecture 'i386'

Now, I installed Docker:

 sudo apt install docker-ce docker-ce-cli \
                  containerd.io docker-buildx-plugin \
                  docker-compose-plugin

Portainer

Now, I want Portainer installed to make managing it remotely much easier. It gives me an interface I can connect to in my browser and start/stop or even create containers.

First, I wanted to make sure I wasn’t setting up conflicting ports:

sudo ss -tunlp

Then, I ran this command to install the container:

sudo docker run -d -p 8000:8000 \
              -p 9443:9443 \
              --name portainer \
              --restart=always \
              -v /var/run/docker.sock:/var/run/docker.sock \
              -v portainer_data:/data \
              portainer/portainer-ce:sts

After it loaded, I went to the address https://<my server>:9443/

When the website came up in the browser, I had to bypass the certificate error. It prompted me to create the admin user. After that, I was in and it was running/installed.

Nginx Proxy

Maybe it’s just because I can, but I’d like to make things nice and provide a unified interface for all my containers. So, I’ll install the Nginx Proxy so I can just put all of the services in one site under different URLs.

The instructions say to use a docker compose file. Just to keep things consistent, I converted it to a command:

sudo docker run -d -p 80:80 \
              -p 443:443 \
              -p 81:81 \
              --add-host host.docker.internal:host-gateway \
              --name webfront \
              --restart=unless-stopped \
              -e TZ="America/New_York" \
              -v nginx_data:/data \
              -v letsencrypt:/etc/letsencrypt \
              jc21/nginx-proxy-manager:latest

Note: I initially left off the letsencrypt volume with the thinking that I wasn’t going to use that. (I planned to only use custom/local certificates.) This is the error that I get:

ERROR: /etc/letsencrypt is not mounted! Check your docker configuration.

Once running, I went to http://<server ip>:81 That asked me to create an account.

I had issues setting up the proxy host. To research, I had to look in the proxy host log file. You can confirm the location in the volumes page of portainer. For me, it was in /var/lib/docker/volumes/nginx_data/_data/logs and the log file was proxy-host-1_error.log

I was able to setup the front page to point to portainer by adding a Proxy Host:

Unfortunately, I was not able to put Portainer under a custom location. Portainer takes one look at the URL and says, I don’t know what to do. So, this didn’t work:

Resources

Leave a Comment

Your email address will not be published. Required fields are marked *