chriscrowe / docker-pihole-unbound

Run Pi-Hole + Unbound on Docker
1.06k stars 275 forks source link

compose file version #112

Closed chrstn-hntschl closed 2 years ago

chrstn-hntschl commented 2 years ago

I believe, some of your definitions (e.g. ${PIHOLE_WEBPORT:-80}:80/tcp in one-container/docker-compose.yaml) require the compose file version to be set to '3' in order to be valid? At least I get errors when doing a docker-compose config:

ERROR: Invalid interpolation format for "ports" option in service "pihole": "${PIHOLE_WEBPORT:-80}:80/tcp"
chriscrowe commented 2 years ago

Whoops, I tested the other variable substitutions but may have forgotten to test this one. Will take a look this evening.

chriscrowe commented 2 years ago

I'm not able to replicate this error; I tried both with and without adding a PIHOLE_WEBPORT entry to my .env file.

What version of docker-compose are you running?

$ docker-compose --version
docker-compose version 1.27.4, build unknown

Also what does your .env file look like? (please remove any secrets before posting)

ChevySSinSD commented 2 years ago

I just tested the latest using a Portainer stack (Portainer v 2.11.1), and had no issues with the latest version. @chriscrowe FYI, I run the stack with the volumes declared at the top with no issue. If I delete the declaration per the readme, I get an error.

From the docker compose documentation, https://docs.docker.com/compose/compose-file/compose-file-v2/#variable-substitution

Both $VARIABLE and ${VARIABLE} syntax are supported. Additionally when using the 2.1 file format, it is possible to provide inline default values using typical shell syntax:

${VARIABLE:-default} evaluates to default if VARIABLE is unset or empty in the environment. ${VARIABLE-default} evaluates to default only if VARIABLE is unset in the environment.

chriscrowe commented 2 years ago

Both $VARIABLE and ${VARIABLE} syntax are supported. Additionally when using the 2.1 file format, it is possible to provide inline default values using typical shell syntax: ${VARIABLE:-default} evaluates to default if VARIABLE is unset or empty in the environment. ${VARIABLE-default} evaluates to default only if VARIABLE is unset in the environment.

Nice find -- I was combing the release notes trying to see if it was added in 3.x but couldn't find it there. Seems like maybe OP might just using an old version of docker-compose

FYI, I run the stack with the volumes declared at the top with no issue. If I delete the declaration per the readme, I get an error.

Gotcha -- I used to run in Portainer (a while ago) and had that issue. Maybe they've fixed it now.

chrstn-hntschl commented 2 years ago

I am using indeed a rather outdated docker-compose version:

$ docker-compose --version
docker-compose version 1.21.0, build unknown

that comes with Raspbian 10. Setting the compose version file version to '2.1' is actually enough to resolve the error - setting to '2' brings:

ERROR: Invalid interpolation format for "ports" option in service "pihole": "${PIHOLE_WEBPORT:-80}:80/tcp"

Here is my .env file:

TZ=Europe/Berlin
WEBPASSWORD=<secret>
REV_SERVER=false
REV_SERVER_DOMAIN=domain.home
REV_SERVER_TARGET=192.168.178.1
REV_SERVER_CIDR=192.168.178.0/24
HOSTNAME=pi.domain.home
DOMAIN_NAME=domain.home
PIHOLE_WEBPORT=80
WEBTHEME=default-light

What I don't understand though is that an outdated docker-compose version parses the config file correctly when increasing the version string. Thanks for your efforts though!

chriscrowe commented 2 years ago

Its weird because it doesn't seem like 2.1 added anything related to this:

https://docs.docker.com/compose/compose-file/compose-versioning/#version-21

Notwithstanding I just tested on 3.0 and everything seems to work so I'll update this on the main branch.