Hello,
I currently have the problem that Docker creates additional volumes for seemingly random containers to which I assign a volume. These additional volumes are then mounted on paths in the container that are already covered by my mount.
An example:
I have two containers in a Docker Compose file, both using subpaths in a volume.
version: '3'
services:
homeassistant:
container_name: homeassistant_justin
image: "ghcr.io/home-assistant/home-assistant:stable"
volumes:
- type: volume
source: data
target: /config
volume:
subpath: homeassistant
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- mosquitto
ports:
- 8123:8123
- 1400:1400
restart: unless-stopped
networks:
justins_homeassistant:
ipv4_address: 172.25.0.2
HomeAssistant_Link:
ipv4_address: 172.21.0.3
mosquitto:
image: eclipse-mosquitto
container_name: mosquitto_justin
restart: unless-stopped
ports:
- 1883:1883
- 8883:8883
volumes:
- type: volume
source: data
target: /mosquitto
volume:
subpath: mosquitto
environment:
- TZ=Europe/Berlin
networks:
justins_homeassistant:
ipv4_address: 172.25.0.3
volumes:
data:
networks:
justins_homeassistant:
driver: bridge
ipam:
config:
- subnet: 172.25.0.0/16
gateway: 172.25.0.1
HomeAssistant_Link:
external: true
- The Home Assistant container runs perfectly fine and only has one volume (
justins_homeassistant_data
) - The Mosquitto container, however, receives the volume I created for it (in this case
justins_homeassistant_data
), and this is mounted in the container at/mosquitto
.
Docker then creates two additional volumes and mounts them at /mosquitto/data
and /mosquitto/log
within the container.
Why does Docker do this, and how can I prevent it? I have already tried deleting and recreating the container without success.