简体   繁体   中英

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

$(...) 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM