Volume using variable with fallback defined in .env file stopped working in compose v2.
.env
VOLUME_SSH_AUTH_SOCK=${SSH_AUTH_SOCK:-/run/host-services/ssh-auth.sock}
docker-compose.yml
# ...
volumes:
# ...
- ${VOLUME_SSH_AUTH_SOCK}:/ssh-agent
produces
error decoding 'Volumes[12]': invalid spec: :-/run/host-services/ssh-auth.sock}:/ssh-agent: empty section between colons
Works when using compose v1.
Works when using v2 only when the fallback of the VOLUME_SSH_AUTH_SOCKis not present or when the fallback is present in the compose file and not in the .env file.
ie.
docker-compose.yml
# ...
volumes:
# ...
- ${SSH_AUTH_SOCK:-/run/host-services/ssh-auth.sock}:/ssh-agent
works in both v1 and v2