Docker on Raspberry Pi keeps creating volumes even if explicitly mapped in docker compose

  Kiến thức lập trình

I’m using the following docker compose file to start a container on the Raspberry Pi running Ubuntu.
The docker version is 26.0.1, build d260a54.
RPI 4, Ubuntu 22.04 server (just CLI) with latest updates 64-bit.

`version: “3.7”

services:
mosquitto:
image: eclipse-mosquitto
hostname: mosquitto
container_name: mosquitto
restart: always
ports:
– “1883:1883”
– “9001:9001”
volumes:
– /var/lib/docker/volumes/mosquitto/config/:/etc/mosquitto
– /var/lib/docker/volumes/mosquitto/config/mosquitto.conf:/mosquitto/config/mosquitto.conf
– /var/lib/docker/volumes/mosquitto/data/:/var/lib/mosquitto/
– /var/lib/docker/volumes/mosquitto/log/:/var/log/mosquitto/
Besides mapped volumes, this docker compose creates two empty volumes on the host machine in/var/lib/docker/volumes/for unknown reasons. The image below presents the situation after two runs ofdocker compose up —d’.
Volumes for the eclipse-mosquitto

Any help eliminating this behaviour (creating empty volumes) would be highly appreciated. Thanks in advance.

Note that stopping and starting a container does not create new volume folders, but issuing docker compose up does cause 2 new volume folders every start.
Each folder contains and empty _data subfolder.

I’ve checked that each mapped volume is accessible and writable from the container level (creating some dummy, empty text files from the container’s sh).

LEAVE A COMMENT