Docker Community Forums

Share and learn in the Docker community.

Docker Compose for Pihole

Hi Guys,

I´m new in using Docker and Docker Compose and have started to build up my system via my docker-compose.yaml file on Ubuntu Server 20.04. I have managed some containers up and running but have been struggling with getting PiHole up and running. In Pihole I got this message when I run docker compose up -d

Error response from daemon: path /home/user/docker/etc-pihole/ is mounted on / but it is not a shared mount.
Error response from daemon: path /home/user/docker/etc-dnsmasq.d/ is mounted on / but it is not a shared mount.

I have tried to solve this problem with the command: sudo mount --make-shared /home/user/docker/etc-pihole/ and sudo mount --make-shared /home/user/docker/etc-dnsmasq.d/ but it is not workning and I got an error saying mount: /home/user/docker/etc-dnsmasq.d: not mount point or bad option and another saying mount: /home/user/docker/etc-pihole: not mount point or bad option.

My docker-compose.yaml script:

  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    restart: always
    hostname: RaspberryPi
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
    environment:
      TZ: 'Sweden/Stockholm'
      WEBPASSWORD: 'my-password'
    # Volumes store your data between container upgrades
    volumes:
      - /home/user/docker/etc-pihole/:/etc/pihole/
      - /home/user/docker/etc-dnsmasq.d/:/etc/dnsmasq.d/
    # Recommended but not required (DHCP needs NET_ADMIN)
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
      - NET_ADMIN

  mosquitto:
    image: eclipse-mosquitto:2.0.14
    hostname: mosquitto
    container_name: mosquitto
    restart: always
    expose:
      - "1883"
      - "9001"
    ports:
      - "1883:1883"
      - "9001:9001"
    volumes:
      - /home/user/docker/mosquitto/config:/mosquitto/config/mosquitto.conf
    networks:
      - default

Any suggestions?

You can try if its possible to enable the mount propgation flag. Since Ubuntu 20.04 uses systemd, thhis should fix it, if run as root(!):

mkdir -p /etc/systemd/system/docker.service.d/
cat <<EOF > /etc/systemd/system/docker.service.d/mount_propagation_flags.conf
[Service]
MountFlags=shared
EOF

systemctl daemon-reload
systemctl restart docker.service

Also: make sure to use docker from docker’s official repositores. The docker.io package of docker is maintained (As in modified, fixed and compiled ) by Ubuntu itself and might not always behave like the “original” docker.