Alfred's New Ramblings

Docker for home use

I have always wanted to try my hand at containers. Containers are a leaner form of virtualization. It allows the VM to tap onto the host OS rather than running multiple copies of the same OS. Docker is the nice layer of software that helps to hold it together.

My first Docker project to dip my toes in is a book manager called Bibliotheca. It helps you to keep track of the books you have read and statistics. Data input and output via browser, so fairly self-contained and does not block anything.

Installation for Docker is easy. Just download Docker Desktop and install Windows Subsystem for Linux (WSL).

According to the Bibliotheca Github page, run the following code in the command window.

docker run -d \
  --name mybibliotheca \
  -p 5054:5054 \
  -v /path/to/data:/app/data \
  -e TIMEZONE=America/Chicago \
  -e WORKERS=6 \
  --restart unless-stopped \
  pickles4evaaaa/mybibliotheca:1.1.1

I converted it to a single long line, and the container was downloaded from Docker Hub and installed. If you used the Docker Desktop GUI to install and left out the port translation, the only way to fix it is to delete the container.

Case matters

C:\Users\Admin>docker run -d --name mybibliotheca -p 5054:5054 -v /path/to/data:/app/data -e TIMEZONE=America/Chicago -e WORKERS=6 --restart unless-stopped pickles4evaaaa/MyBibliotheca:latest
docker: invalid reference format: repository name (pickles4evaaaa/MyBibliotheca) must be lowercase

A successful install

C:\Users\Admin>docker run -d --name mybibliotheca -p 5054:5054 -v /path/to/data:/app/data -e TIMEZONE=America/Chicago -e WORKERS=6 --restart unless-stopped pickles4evaaaa/mybibliotheca:latest
0e41f1fd8e0ef7b11df354c59bf725e11157f2623b3ee16e4318e41371fb5aa9

List of downloaded images which containers are based on

C:\Users\Admin>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
pickles4evaaaa/mybibliotheca latest bdeba291d9cb 2 days ago 930MB

Downloading a new image to perform an upgrade.

C:\Users\Admin>docker pull pickles4evaaaa/bibliotheca:1.1.0
1.1.0: Pulling from pickles4evaaaa/bibliotheca
5f70ed490464: Pull complete
920295a7923a: Pull complete
733e2cf0f6d8: Pull complete
7acd0644573a: Pull complete
Digest: sha256:7844b65010f6677cce679c1d7c3fbce9806ace13d5b8792abafbc19c4a64232b
Status: Downloaded newer image for pickles4evaaaa/bibliotheca:1.1.0
docker.io/pickles4evaaaa/bibliotheca:1.1.0

List of downloaded images and running container

C:\Users\Admin>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
pickles4evaaaa/mybibliotheca latest bdeba291d9cb 2 days ago 930MB
pickles4evaaaa/bibliotheca 1.1.0 7844b65010f6 5 days ago 317MB
C:\Users\Admin>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0e41f1fd8e0e pickles4evaaaa/mybibliotheca:latest "docker-entrypoint.s…" 3 hours ago Up 3 hours 0.0.0.0:5054->5054/tcp mybibliotheca

Upgrading the container

Stop the container, delete and start the new version.

C:\Users\Admin>docker stop 0e41f1fd8e0e
0e41f1fd8e0e
C:\Users\Admin>docker rm 0e41f1fd8e0e
0e41f1fd8e0e
C:\Users\Admin>docker run -d --name bibliotheca -p 5054:5054 -v /path/to/data:/app/data -e TIMEZONE=America/Chicago -e WORKERS=6 --restart unless-stopped pickles4evaaaa/bibliotheca:1.1.0
3f802e2213104b63f8dfab486bf2cca5e10536947f5e8cd313b72a165f725675
C:\Users\Admin>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3f802e221310 pickles4evaaaa/bibliotheca:1.1.0 "sh -c 'gunicorn -w …" 15 seconds ago Up 15 seconds 0.0.0.0:5054->5054/tcp bibliotheca

The upgrade is very smooth and very resilient. The data persists even after all the containers and images were deleted. I wanted to delete all data and start from scratch, but it is not possible.

Tagged on: ,



Leave a Reply

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