JustToThePoint English Website Version
JustToThePoint en español

Docker Containers. From Basics to Real-World Workflows

To err is human, to blame it on someone else is even more human, Jacob’s Law

Topology and Limits

Introduction

Docker is a software platform designed to make it easier to create, deploy, and run applications by using containers. It offers OS-level virtualization to deliver software in packages called containers. Image

Common Docker Commands

❯ docker ps
CONTAINER ID   IMAGE                                    COMMAND                  CREATED         STATUS         PORTS                                                           NAMES
3e457e3d46a1   nginx                                    "/docker-entrypoint.…"   3 minutes ago   Up 3 minutes   0.0.0.0:8080->80/tcp, :::8080->80/tcp                           web
18a5b83591dd   lscr.io/linuxserver/libreoffice:latest   "/init"                  22 hours ago    Up 7 hours     0.0.0.0:3000-3001->3000-3001/tcp, :::3000-3001->3000-3001/tcp   libreoffice

nmaximo7 on nixos ~
❯ docker stop web
web

nmaximo7 on nixos ~
# Delete the container
❯ docker rm web
Error response from daemon: No such container: web
# It typically means Docker has already removed the container.

# If you have many stopped containers and want to remove all at once:
docker container prune

# It forcefully removes all Docker containers on your system —both running and stopped.
# This is a safe and standard way to clean up all containers if you want to start fresh or free up resources.
sudo docker rm -f $(sudo docker ps -a -q)

Running GUI Applications in Containers

Firefox

Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. This command effectively sets up a Firefox container with specified configurations, ready for use in http://localhost:3000 or https://localhost:3001.

docker run -d \ # It runs the container in the background (detached mode).
  --name=firefox \ # It assigns the name "firefox" to the container for easy reference and management.
  --security-opt seccomp=unconfined \ # It disables seccomp security profile for the container. This is a Linux kernel feature that acts like a filter for system calls (syscalls) that a process inside a container can make.
  -e PUID=1000 \ # Set the user ID for the container (typically the user ID of the host).
  -e PGID=1000 \ # Set the group ID for the container (typically the group ID of the host).
  -e TZ=Europe/Madrid \ # Set the timezone to Europe/Madrid.
  -e FIREFOX_CLI=https://www.linuxserver.io/ \ # Set the URL for Firefox to open
  -p 3000:3000 \ # Map port 3000 on the host to port 3000 in the container. Firefox desktop gui.
  -p 3001:3001 \ # Map port 3001 on the host to port 3001 in the container. 	Firefox desktop gui HTTPS.
  --shm-size="1gb" \ # Set shared memory size to 1GB (useful for applications with high memory needs).
  --restart unless-stopped \ # Restart the container automatically unless it is stopped manually
  lscr.io/linuxserver/firefox:latest # Specify the Docker image to use.

Obsidian

Obsidian is a powerful note-taking and knowledge management app designed to help you build your own personal second brain. This command effectively sets up an Obsidian container ready for use in http://localhost:3000 or https://localhost:3001, exposing the vault at /vault.

docker run -d \ # It runs the container in the background (detached mode).
  --name=obsidian \ # It assigns the name "obsidian" to the container for easy reference and management.
  --security-opt seccomp=unconfined \ # It disables seccomp security profile for the container. This is a Linux kernel feature that acts like a filter for system calls (syscalls) that a process inside a container can make.
  -e PUID=1000 \ # Set the user ID for the container (typically the user ID of the host).
  -e PGID=1000 \ # Set the group ID for the container (typically the group ID of the host).
  -e TZ=Europe/Madrid \ # Set the timezone to Europe/Madrid.
  -p 3000:3000 \ # Map port 3000 on the host to port 3000 in the container. Obsidian desktop gui.
  -p 3001:3001 \ # Map port 3001 on the host to port 3001 in the container. 	Obsidian desktop gui HTTPS.
  --device /dev/dri:/dev/dri \ # Add this for GL support (Linux hosts only).
  # OpenGL (Open Graphics Library) is a cross-platform API used for rendering 2D and 3D graphics. It's widely used in games, simulations, and graphical applications.
  --shm-size="1gb" \ # Set shared memory size to 1GB (useful for applications with high memory needs).
  --restart unless-stopped \ # Restart the container automatically unless it is stopped manually
  -v ~/dotfiles/docs:/vault:rw \
  # It mounts your local ~/dotfiles/docs directory to /vault inside the container with read/write permissions.
  lscr.io/linuxserver/obsidian:latest # Specify the Docker image to use.

Open your favorite browser, navigate to http://localhost:3000/, select Open folder as vault, + Other locations, vault, and smash the Open button. Then, trust author and enable plugins.

LibreOffice

LibreOffice is a free and open-source office suite that offers a powerful alternative to Microsoft Office. It is available for Windows, macOS, and Linux.

docker run -d \ # It runs the container in the background (detached mode).
  --name=libreoffice \ # It assigns the name "libreoffice" to the container for easy reference and management.
  --security-opt seccomp=unconfined \ # It disables seccomp security profile for the container. This is a Linux kernel feature that acts like a filter for system calls (syscalls) that a process inside a container can make.
  -e PUID=1000 \ # Set the user ID for the container (typically the user ID of the host).
  -e PGID=1000 \ # Set the group ID for the container (typically the group ID of the host).
  -e TZ=Europe/Madrid \ # Set the timezone to Europe/Madrid.
  -p 3000:3000 \ # Map port 3000 on the host to port 3000 in the container. Obsidian desktop gui.
  -p 3001:3001 \ # Map port 3001 on the host to port 3001 in the container. 	Obsidian desktop gui HTTPS.
  --restart unless-stopped \ # Restart the container automatically unless it is stopped manually
  lscr.io/linuxserver/libreoffice:latest # Specify the Docker image to use.

Web Servers with Nginx

Nginx is a versatile open-source software that functions primarily as a web server, reverse proxy, load balancer, and HTTP cache. Let’s spin up a lightweight NGINX web server container — nice and snappy with the following command: docker run -it --rm -d -p 8080:80 --name web nginx

Once this runs, you can open your browser and visit http://localhost:8080 to see the default NGINX welcome page. It’s a perfect sandbox for local testing or quick HTTP serving.

Serving a Hugo Site

Assuming our Hugo site output is in ~/justtothepoint/public. Let’s publish our static Hugo site with Docker and NGINX: docker run --rm -d -p 8080:80 --name web -v ~/justtothepoint/public:/usr/share/nginx/html nginx

The -v (or –volume) option is used to mount a directory from your local machine into the container

Open your browser and go to http://localhost:8080 — voilà! Your Hugo site is live via NGINX!

Ollama: Local AI API

docker run -d \
  -v ollama_data:/root/.ollama \        # Persistent models in ollama_data volume
  -p 127.0.0.1:11434:11434 \            # Port mapping. Maps container port 11434 to localhost:11434.
  -e OLLAMA_HOST="0.0.0.0:11434" \      # Ollama listens on all interfaces
  -e OLLAMA_DEBUG="1" \                 # Enable debug logging
  -e OLLAMA_KEEP_ALIVE="10m" \          # Keep models in memory for 10 minutes
  --name my_ollama \                    # Container name
  ollama/ollama                         # Official
  Ollama image

# Download models
docker exec -it my_ollama ollama pull llama3.2
# Chat with models
docker exec -it my_ollama ollama run llama3.2

# Stop the current container
docker stop my_ollama
docker rm my_ollama
Bitcoin donation

JustToThePoint Copyright © 2011 - 2025 Anawim. ALL RIGHTS RESERVED. Bilingual e-books, articles, and videos to help your child and your entire family succeed, develop a healthy lifestyle, and have a lot of fun. Social Issues, Join us.

This website uses cookies to improve your navigation experience.
By continuing, you are consenting to our use of cookies, in accordance with our Cookies Policy and Website Terms and Conditions of use.