Need Docker Compose File Creation Help

Hey Folks

I run docker on Synology NAS. New to docker-compose and trying to create that file as I believe that is better than "docker run" ?

Here is what I have copied and modifed for the yml file.

version: "3"

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    network_mode: "host"
    environment:
      TZ: 'XXXX\XXXXX'
      WEBPASSWORD: 'password'
      DNSMASQ_LISTENING: 'all'
      WEB_PORT: '7113'
      ServerIP: '192.168.X.X'
    volumes:
       - '/volume1/docker/pihole/hosts/hosts:/etc/hosts'
       - '/volume1/docker/pihole/dnsmasq.d:/etc/dnsmasq.d'
       - '/volume1/docker/pihole:/etc/pihole'
    dns:
      - 127.0.0.1
      - 1.1.1.1
    cap_add:
      - NET_ADMIN
    restart: unless-stopped
    labels:
      - "com.centurylinklabs.watchtower.enable=false"

Had a few basic questions

  1. Does the file look good? anything wrong or missing? (have replaced some sensitive data with XXX)

  2. How do I make sure whenever it starts, it has CloudFlare IP's for DNS?

  3. When I have the file docker-compose.yml in a folder and I do "docker-compose up" the result stays there until I do CTRL+C and it breaks and stops the container. How do I use the file to just raise the container and then quit to command line gracefully?

Creating pihole...
Creating pihole... done
Attaching to pihole
pihole | WARNING: no logs are available with the 'db' log driver

^CGracefully stopping... (press Ctrl+C again to force)
Stopping pihole ... done

  1. If I ever want to update using the yml file, how do I do so? Currently I use Synology NAS GUI - stop it, click on clear, and then do a "docker pull pihole/pihole" and then start again via GUI. Is there a 1 command way to update via compose file?

  2. Even thought I have "restart: unless-stopped" the Synology GUI for docker doesn't show the "enable auto-restart" ticked? What is wrong there?

Just trying to figure out what is the best way to deploy and maintain docker

  1. Looks fine to me. Mostly lines up with the examples we provide in our github repo.
  2. GitHub - pi-hole/docker-pi-hole: Pi-hole in a docker container DNS1 DNS2 Environment
  3. docker-compose up -d will background it, docker-compose logs if you want to attach to it without having ctrl+c end the container (use down or stop for that)
  4. Since you're using latest you should just run the following docker-compose subcommand in succession: pull, down, up (pull before up in case your DNS breaks docker when the container goes down and you can't connect out)
  5. I'd guess it is expecting restart: always, which is a more aggressive form of restart: unless-stopped and since it doesn't match exactly it didn't know about the setting.
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.