Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add $(...) in Docker Compose

I have a docker-compose.yml which contains the stuff to start a jenkins-server on CentOS7:

jenkins:
  image: jenkins
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - $(which docker):/usr/bin/docker:ro
    - /usr/lib64/libsystemd-journal.so.0:/usr/lib/x86_64-linux-gnu/libsystemd-journal.so.0
    - /usr/lib64/libsystemd-id128.so.0:/usr/lib/x86_64-linux-gnu/libsystemd-id128.so.0
    - /usr/lib64/libdevmapper.so.1.02:/usr/lib/x86_64-linux-gnu/libdevmapper.so.1.02
    - /usr/lib64/libgcrypt.so.11:/usr/lib/x86_64-linux-gnu/libgcrypt.so.11
    - /usr/lib64/libdw.so.1:/usr/lib/x86_64-linux-gnu/libdw.so.1
  ports:
    - "8080:8080"

But I'm not able to run the compose because I keep getting an error on $(which docker):/usr/bin/docker:ro. How do I have to fix this?

Error: ERROR: Invalid interpolation format for "volumes" option in service "jenkins": "$(which docker):/usr/bin/docker:ro"

Is it still not possible to include environment variables? I'm searching for the most right solution. Thanks

like image 393
lvthillo Avatar asked Jan 12 '16 10:01

lvthillo


1 Answers

$(...) is not an environment variable, it's command substituion.

You need to use an environment variable to pass in the value.

DOCKER_PATH=$(which docker) docker-compose up

docker-compose.yaml (snippet)

- ${DOCKER_PATH}:/usr/bin/docker:ro
like image 93
dnephin Avatar answered Sep 30 '22 17:09

dnephin