Expected behavior
docker-compose.yml should interpret environment variables, eg:
test:
build: .
dockerfile: Dockerfile
environment:
- HOST_HOSTNAME=${HOSTNAME}
should result in HOST_HOSTNAME being set to the host’s hostname in the container.
Actual behavior
> echo $HOSTNAME
foo
> docker-compose up
WARNING: The HOSTNAME variable is not set. Defaulting to a blank string.
...
Information
- a reproducible case if this is a bug, Dockerfiles FTW
Dockerfile:
FROM alpine:3.3
RUN apk --no-cache add coreutils
CMD [ "env" ]
docker-compose.yml:
test:
build: .
dockerfile: Dockerfile
environment:
- HOST_HOSTNAME=${HOSTNAME}
Expected output:
test_1 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
test_1 | HOSTNAME=63d376bcaa02
test_1 | HOST_HOSTNAME=foo
test_1 | HOME=/root
Actual output:
test_1 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
test_1 | HOSTNAME=63d376bcaa02
test_1 | HOST_HOSTNAME=
test_1 | HOME=/root
- host distribution and version ( OSX 10.10.x, OSX 10.11.x, Windows, etc )
OSX:
10.11.4 (15E65)
Docker for Mac:
Version 1.11.1-beta11 (build: 6974)
37559e5f6acd56a4810963acc7001e88f2d88017
docker-compose:
docker-compose version 1.7.1, build 0a9ab35