Guy’s

I’m taking my first steps in docker&portainer.

I want to begin with pihole container as a stack and I’m using below example to create it. Volumes I create are not used, why? What do I need to do? I’ve created them earlier in “Volumes” tab. What else I need to do?

version: "3"
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "80:80/tcp"
    environment:
      # WEBPASSWORD: 'password'
    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
    restart: unless-stopped

  • james-portainer@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    You’re using relative paths in your volumes:

    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
    

    When using compose from the command line, these volumes would be mounted as bind mounts with relative paths to where you ran the docker compose up command - for example, if you were in /tmp/pihole they would be at /tmp/pihole/etc-pihole and /tmp/pihole/etc-dnsmasq.d. In Portainer, because we run the compose commands from within the Portainer container’s file system rather than on the host environment, the relative path is relative to the Portainer container’s file system.

    If these file paths exist on your host filesystem, you could change the relative paths to absolute paths instead:

    volumes:
      - /path/to/etc-pihole:/etc/pihole
      - /path/to/etc-dnsmasq.d:/etc/dnsmasq.d
    

    Or, if they don’t exist and are populated by the container image on first deploy, you could create them as named volumes:

    services:
      pihole:
        ...
        volumes:
          - etc-pihole:/etc/pihole
          - etc-dnsmasq.d:/etc/dnsmasq.d
    
    volumes:
      etc-pihole:
      etc-dnsmasq.d:
    

    Your method will depend on your requirements and what the image itself expects and provides.