Containers

Install Docker and Docker Compose on Linux Mint 22

The newest Linux Mint release calls itself zena, and Docker’s repository has never heard of it. That one mismatch is why Ubuntu instructions copied onto Mint stop at apt update: they build the repo line from lsb_release -cs, which returns Mint’s codename instead of the Ubuntu release Mint is built on. Point the repo at the Ubuntu base and you can install Docker on Linux Mint with the same packages Ubuntu gets, Compose plugin included.

Original content from computingforgeeks.com - post 7449

You will reproduce that error, fix the repo, install Docker Engine and Docker Compose, and drop the sudo requirement. Then you run an nginx page and a PHP plus MariaDB stack, and the last section covers the four errors we hit along the way. We reran every step on Linux Mint 22.3 (Ubuntu 24.04 noble base) in November 2026 with Docker Engine 29.10.1 and Compose v5.8.1.

Why the Ubuntu commands fail on Linux Mint

Mint keeps two codenames in /etc/os-release, its own release name and the Ubuntu release underneath it. Docker publishes packages only for Ubuntu codenames, so the repo line has to carry the Ubuntu one. Docker’s Ubuntu install page says derivatives such as Mint aren’t officially supported, though they may work, and on our Mint machine every step below did. On the current Mint 22.x release the names line up like this:

  • Mint release name: zena, from lsb_release and VERSION_CODENAME
  • Ubuntu base: noble, from UBUNTU_CODENAME
  • Suite Docker’s repo serves: noble

Check both values before you touch apt. It takes two seconds, tells you which suite to expect later, and is the first thing to run whenever an Ubuntu tutorial misbehaves on Mint.

lsb_release -cs
grep -E "VERSION_CODENAME|UBUNTU_CODENAME" /etc/os-release

To see what a Mint user actually gets, we then added the repo the way most Ubuntu guides still do, with $(lsb_release -cs) in the line. The line came out as https://download.docker.com/linux/ubuntu zena stable, and apt update refused it. The Mint mirrors loaded fine; only Docker’s line failed.

Docker repo line built from lsb_release returns zena and apt update fails on Linux Mint

Run without the grep filter, the same apt update also prints 404 Not Found under the Err line, because there is no zena directory under Docker’s Ubuntu dists. If you already have that broken line, delete it before going further, since every apt update ends in the same error while it exists. It usually lives in docker.list.

sudo rm -f /etc/apt/sources.list.d/docker.list

Mint 21.x has the same split with jammy as its Ubuntu base, and the Mint project lists every 21.x release as jammy based and supported until April 2027. Docker still lists Jammy 22.04 among its supported Ubuntu releases, so the commands below apply unchanged there: the Suites line simply reads jammy instead of noble, and you should confirm that before installing. LMDE, the Debian edition of Mint, is built on Debian rather than Ubuntu, so it needs the Debian repo instead, as in our Docker CE on Debian guide.

Remove the old Docker packages

Mint’s Software Manager offers docker.io from the Ubuntu archive, and it’s tempting because it is one click. It’s also behind. On our machine the archive candidate was nine minor releases older than Docker’s own engine, and its docker-compose-v2 package trailed the current Compose by three major versions. The two sets conflict over containerd and runc, so you should clear out any archive Docker first.

sudo apt remove -y $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc 2>/dev/null | cut -f1)

The dpkg filter passes only installed packages to apt, so on a fresh Mint install this removes nothing and reports zero changes. Removing the packages does not delete Docker’s data either. Volumes live under /var/lib/docker, and since Docker 29 uses the containerd image store on fresh installs, image data sits in containerd’s own data directory. Neither goes away with the packages, so delete them yourself only when you want a truly clean start.

Add the Docker repository for the Ubuntu base

Install the two tools the setup needs and store Docker’s signing key in its own keyring, so apt trusts it only for Docker’s packages. The Signed-By line in the next step points at this exact file, so keep the path as shown.

sudo apt update
sudo apt install -y 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

Now write the source file. The suite comes from UBUNTU_CODENAME, which is the whole fix, and it falls back to VERSION_CODENAME so the same line also works on plain Ubuntu. The deb822 format keeps each field on its own line, which makes the suite easy to check.

printf 'Types: deb\nURIs: https://download.docker.com/linux/%s\nSuites: %s\nComponents: stable\nArchitectures: %s\nSigned-By: /etc/apt/keyrings/docker.asc\n' "ubuntu" "$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")" "$(dpkg --print-architecture)" | sudo tee /etc/apt/sources.list.d/docker.sources

Read the Suites line that tee echoes back before you go on. It must say noble on Mint 22.x, and a refresh should then fetch Docker’s noble index without errors.

docker.sources file on Linux Mint with Suites noble and apt fetching Docker packages

If the line says zena or another Mint name, the variable did not expand and apt will fail exactly as before, so rerun the command. Mint’s own repositories and the Ubuntu archive still serve everything else; this file adds one source rather than turning the system into Ubuntu. When you later move to a Mint release on a newer Ubuntu base, rerun the printf line so the suite follows the new codename.

Install Docker and the Compose plugin

Install the engine, CLI, containerd, Buildx and Compose in one command. Compose ships as a plugin to the Docker CLI, so this is the only install step it needs, and it updates with the rest of Docker through Mint’s Update Manager.

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

apt pulled seven packages, 94.1 MB to download and 379 MB on disk, in under 18 seconds. Both services came up active and Docker is enabled at boot, so there’s no systemctl enable step for you to remember.

apt installing docker-ce and the Compose plugin on Linux Mint with docker and containerd active

Prove the engine works by running a test image, which exercises the client, the daemon and a pull from Docker Hub in one go. You still need sudo here, because your user isn’t in the docker group yet.

sudo docker run --rm hello-world

The image is pulled and prints its greeting; the output below is trimmed to the pull summary and the first lines of the message. A “Cannot connect to the Docker daemon” message instead means the service is not running, so check systemctl status docker. A pull timeout points at DNS or a proxy rather than Docker itself.

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
4f55086f7dd0: Pull complete
Digest: sha256:1e4c05b897a751332ce85c7e9449da2d93514ea2dea6dbb0e2753c9e949b2bfa
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

The same packages and repo setup work on Ubuntu itself; our Docker and Compose guide for Ubuntu and Debian covers those servers, including the UFW gap that published ports open.

Use Docker without sudo

On a desktop you will run Docker all day, so typing sudo each time gets in the way. Add your account to the docker group. Treat that like handing out sudo, because anyone in the group can start a container that mounts your whole filesystem as root. On a single-user laptop that trade is usually fine.

sudo usermod -aG docker $USER
newgrp docker

newgrp only applies to the terminal you ran it in. Log out of the desktop session and back in, and every new terminal picks up the group, because membership is read at login. Then check the versions without sudo.

docker version --format "Client {{.Client.Version}}, Server {{.Server.Version}}"
docker compose version
apt-cache policy docker-ce | sed -n 1,3p

Client and server match, Compose answers as a subcommand, and the package version ends in ubuntu.24.04~noble, which confirms apt took it from Docker’s noble suite and not the archive.

docker version and docker compose version on Linux Mint without sudo

If docker version prints the client but a permission error for the server part, your session hasn’t picked up the group yet. Log out once more rather than adding sudo back, because group membership is only read at login.

Run a first Compose project

A small project shows the Compose workflow without pulling gigabytes: one nginx container serving a page from a folder in your home directory. Create the folder and the page first, so the container has something to serve when it starts.

mkdir -p ~/hello-compose/html
cd ~/hello-compose
echo "<h1>Compose on Linux Mint</h1>" > html/index.html

Compose reads compose.yaml from the current directory and names the project after that directory, which is why the container below is called hello-compose-web-1. Create the file.

vim ~/hello-compose/compose.yaml

Add the service. The port is bound to 127.0.0.1 on purpose, because a laptop moves between networks and a plain 8080:80 would expose the container to everyone on the cafe Wi-Fi. Docker’s port rules sit ahead of UFW, so the firewall wouldn’t stop it.

services:
  web:
    image: nginx:alpine
    ports:
      - "127.0.0.1:8080:80"
    volumes:
      - ./html:/usr/share/nginx/html:ro
    restart: unless-stopped

Start it in the background and fetch the page. --wait returns only once the container is running, so the curl right after it does not race the startup.

docker compose up -d --wait
docker compose ps
curl -s localhost:8080

The container is up, the port is bound to loopback only, and nginx returns your page. If PORTS shows 0.0.0.0 instead, the 127.0.0.1: prefix is missing from the port line and the service is reachable from the network.

NAME                  IMAGE          COMMAND                  SERVICE   CREATED        STATUS                  PORTS
hello-compose-web-1   nginx:alpine   "/docker-entrypoint.…"   web       1 second ago   Up Less than a second   127.0.0.1:8080->80/tcp
<h1>Compose on Linux Mint</h1>

Edit html/index.html and reload to see the bind mount at work, since the container reads the file straight from your home folder. Run docker compose down in the folder when you’re done, which removes the container and the project network.

Run a PHP and MariaDB stack with Compose

One container doesn’t show why Compose exists. Two services that depend on each other do, so this project runs Apache with PHP in front of MariaDB, the classic LAMP pair. It replaces the examples from our older Docker Compose on Linux Mint guide, rebuilt and rerun on Mint 22. You need four files in one folder.

  • .env: database credentials, read by both services
  • Dockerfile: the PHP image plus the mysqli extension
  • compose.yaml: the two services, a volume and the start order
  • html/index.php: a page that queries the database

Start with the folder and random passwords. Generating them with openssl keeps real secrets out of the YAML, and chmod 600 keeps other local users from reading them. Compose reads the file itself, so the services still get the values.

mkdir -p ~/docker-lamp/html
cd ~/docker-lamp
printf 'MARIADB_ROOT_PASSWORD=%s\nMARIADB_DATABASE=appdb\nMARIADB_USER=appuser\nMARIADB_PASSWORD=%s\n' "$(openssl rand -hex 16)" "$(openssl rand -hex 16)" > .env
chmod 600 .env

The official php:8-apache image does not include mysqli, so a page that calls mysqli_connect() dies with a fatal error on the stock image. A two-line Dockerfile adds it with the image’s own helper script, which compiles the extension once at build time instead of on every start.

vim ~/docker-lamp/Dockerfile

Paste these two lines into the file and save it. You can add more extensions to the same RUN line later, separated by spaces.

FROM php:8-apache
RUN docker-php-ext-install mysqli

Next comes the Compose file, which ties the image, the database and the credentials together. Open it in the same folder.

vim ~/docker-lamp/compose.yaml

The depends_on block with condition: service_healthy is what makes Compose worth using here. PHP does not start until MariaDB’s own healthcheck.sh confirms InnoDB is initialized, so the first page load never hits a database that is still creating its files. The old links: key from Compose v1 files is not needed, because services on the project network already reach each other by name. That is why the PHP code connects to the host db.

services:
  web:
    build: .
    ports:
      - "127.0.0.1:8080:80"
    volumes:
      - ./html:/var/www/html:ro
    env_file: .env
    depends_on:
      db:
        condition: service_healthy
    restart: unless-stopped

  db:
    image: mariadb:11
    volumes:
      - dbdata:/var/lib/mysql
    env_file: .env
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 5s
      timeout: 5s
      retries: 10
    restart: unless-stopped

volumes:
  dbdata:

The last file is the page itself. It reads the same credentials from the environment, so no password ever lands in the PHP code.

vim ~/docker-lamp/html/index.php

Add these lines, which connect to the host db and print both server versions.

<?php
$db = mysqli_connect('db', getenv('MARIADB_USER'), getenv('MARIADB_PASSWORD'), getenv('MARIADB_DATABASE'));
echo "<h1>LAMP on Linux Mint</h1>";
echo "<p>PHP " . PHP_VERSION . " talking to MariaDB " . mysqli_get_server_info($db) . "</p>";

With the four files in place, bring the stack up in two steps. Starting the database on its own first lets you watch its health check pass before PHP joins it.

Start one service on its own

Name a service after up and Compose starts only that one, plus anything it depends on. That’s also handy later, when you only need the database for a migration or a test run.

docker compose up -d --wait db
docker compose ps

It took 18 seconds on our machine, nearly all of it MariaDB initializing its data directory on the first run, and docker compose ps then listed only the database.

NAME               IMAGE        COMMAND                  SERVICE   CREATED          STATUS                    PORTS
docker-lamp-db-1   mariadb:11   "docker-entrypoint.s…"   db        14 seconds ago   Up 10 seconds (healthy)   3306/tcp

Port 3306 shows without a host mapping, so only containers on the project network can reach it. Nothing on your LAN or even on the host can connect to MariaDB directly.

Build the PHP image and start the web service

Now run up without a service name. --build runs the Dockerfile first, and --wait holds the prompt until MariaDB reports healthy and the web container is running.

docker compose up -d --wait --build
docker compose ps

MariaDB had been up for 27 seconds and was already healthy, so depends_on had nothing to wait for and the web container started at once. On a cold start of both services, the same service_healthy condition makes Compose hold PHP back until the database check passes.

docker compose up --build starts the PHP service next to a healthy MariaDB container on Linux Mint

Fetch the page to test the whole chain. Our first attempt printed a permission error here instead, which the “Failed opening required” fix in the errors section covers.

curl -s localhost:8080

With index.php readable, the page answers from the running stack:

<h1>LAMP on Linux Mint</h1><p>PHP 8.6.0 talking to MariaDB 11.8.10-MariaDB-ubu2404</p>

That line proves Apache served PHP, PHP loaded mysqli, and mysqli reached MariaDB over the project network. A browser pointed at http://localhost:8080 shows the same heading, and nothing outside the machine can reach it because of the loopback binding.

Use exec, run and logs

These three cover most day-to-day work, and the difference between the first two trips people up. Pick the one that matches whether you want the running container or a fresh one.

  • exec runs a command inside the container that is already running
  • run starts a new, one-off container from the service definition
  • logs prints what a service wrote to stdout and stderr

Use exec to query the live database with the credentials from .env, without exposing port 3306 to the host.

docker compose exec db mariadb -u appuser -p"$(grep ^MARIADB_PASSWORD .env | cut -d= -f2)" appdb -e "SELECT VERSION();"

The answer comes from the running server, so it matches what the PHP page printed. Drop the -e part and you get an interactive MariaDB prompt instead.

VERSION()
11.8.10-MariaDB-ubu2404

run suits checks you’d rather keep away from the live container. --rm deletes the one-off container afterwards and --no-deps skips starting the database again. Here it confirms the built image really carries mysqli, then you tail the database log.

docker compose run --rm --no-deps web php -m | grep -i mysqli
docker compose run --rm --no-deps web php -v | head -1
docker compose logs db | grep "ready for connections" | tail -2

Each run created its own throwaway container, named with a random suffix, and removed it on exit. MariaDB logs “ready for connections” twice on a first start, once for the temporary server the entrypoint uses to create the user and database, and once for the real one.

docker compose run and docker compose logs against the PHP and MariaDB services

Add -f to logs to follow the output live while you reload the page. Without a service name, logs interleaves every service, each line prefixed with its service name, like the db-1 above.

Stop the stack and keep the data

docker compose down removes the containers and the network but leaves named volumes alone, so the database survives. You can check that from the host after the containers are gone.

docker compose down
docker volume ls --filter name=docker-lamp

The dbdata volume is still there, prefixed with the project name, because Compose namespaces everything it creates by the folder name. We trimmed the down output to its last four lines; the web container’s Removing and Removed lines come first.

 Container docker-lamp-db-1 Removing
 Container docker-lamp-db-1 Removed
 Network docker-lamp_default Removing
 Network docker-lamp_default Removed
DRIVER    VOLUME NAME
local     docker-lamp_dbdata

A later docker compose up -d --wait brought both services back healthy on that existing volume. When you want the database gone too, docker compose down -v also deletes the named volumes declared in the file, so keep it for test projects. For more patterns, the guide to managing containers with Docker Compose goes further, and Portainer puts a web UI over the same engine.

Fix common Docker Compose errors on Linux Mint

Three of these four came up unprompted while we built the projects above, and we triggered the fourth on purpose to capture its exact text. They are not specific to Mint, but every Mint user who follows an older tutorial meets them.

Call to undefined function mysqli_connect()

Older Compose examples use image: php:8-apache directly. That image ships without mysqli, and running the call against the stock image shows it straight away.

docker run --rm php:8-apache php -r 'mysqli_connect("db");'

PHP stops at the first line of the script, and a web page built this way shows the same fatal error in place of its content.

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in Command line code:1

Switch the service to build: . with the two-line Dockerfile from the stack above and run docker compose up -d --build. Use docker-php-ext-install pdo_mysql instead if your code uses PDO.

Failed opening required ‘/var/www/html/index.php’

Our first curl against the LAMP stack returned this instead of the page, even though both containers were healthy. Health checks only prove the processes run, not that Apache can read your files.

<b>Warning</b>:  Unknown: Failed to open stream: Permission denied in <b>Unknown</b> on line <b>0</b><br />
<b>Fatal error</b>:  Failed opening required '/var/www/html/index.php' (include_path='.:') in <b>Unknown</b> on line <b>0</b><br />

The cause was the file mode on the host. index.php had been copied with mode 600, so only our user could read it, while Apache inside the container runs as www-data. A bind mount passes host permissions through unchanged, and :ro means the container cannot fix them either. Make the file world readable and reload.

chmod 644 ~/docker-lamp/html/index.php

The next request returned the LAMP page with no restart needed. Watch for this whenever your umask is 077 or files come from an encrypted home folder or a tarball that preserved tight modes.

The attribute `version` is obsolete

Compose files written for v1 start with a line such as version: '3'. Compose v2 and later ignore it and say so on every command. We prepended that line to a copy of our file to show you the exact message.

Docker Compose warning that the version attribute is obsolete

It’s a warning, not a failure: both services still parsed. Docker’s Compose file reference says the field is informative only and Compose always validates against the latest schema, so delete the line and the warning goes away.

docker-compose: command not found

The Compose plugin installs docker compose with a space, and nothing provides the old hyphenated command. Scripts, Makefiles and README files written for Compose v1 call docker-compose, and on our fresh Mint install the shell answered with docker-compose: command not found. Don’t install the old standalone v1 binary to fix it, because Compose v1 is end of life. A two-line wrapper that hands every argument to the plugin is enough.

printf '#!/bin/sh\nexec docker compose "$@"\n' | sudo tee /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Before the wrapper, the shell could not find the command. After it, docker-compose reports the plugin version and drives the running LAMP project exactly as the space form does, so you can point old scripts at it unchanged.

docker-compose wrapper script calling docker compose on Linux Mint

Because the wrapper lives in /usr/local/bin, apt upgrades never touch it, and it always runs whatever plugin version is installed. Move your own scripts to the space form when you next edit them and keep the wrapper for third-party tools you can’t change. For the same install on Fedora, Rocky Linux or Debian, our Docker install guide for Linux covers each package manager, and if containers are new to you, one of the Docker books we recommend explains images and volumes properly before you build anything bigger.

Keep reading

Backup and Restore Linux Systems with Timeshift Debian Backup and Restore Linux Systems with Timeshift How To Install Wine on Linux Mint 22.3 / 22.2 / 22.1 Linux Mint How To Install Wine on Linux Mint 22.3 / 22.2 / 22.1 Best UI Applications for Managing Docker Containers Containers Best UI Applications for Managing Docker Containers Traefik 3.8 Upgrade: Breaking Changes, Yaegi v2 and Helm Test Containers Traefik 3.8 Upgrade: Breaking Changes, Yaegi v2 and Helm Test magpie: One AI Gateway for Claude Code and Codex on Linux AI magpie: One AI Gateway for Claude Code and Codex on Linux Langflow CVE-2026-110186: Check, Fix and Harden Docker Containers Langflow CVE-2026-110186: Check, Fix and Harden Docker

3 thoughts on “Install Docker and Docker Compose on Linux Mint 22”

Leave a Comment

Press ESC to close