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

I need to run the following commands in the docker-compose file:

- '/var/run/docker.sock:/var/run/docker.sock'
- '$(which docker):$(which docker)'

I found a solution for this format:

- ${DOCKER_PATH}:/usr/bin/docker:ro

But in my case, I need to run this format $ (..): $ (..),

Is there any simple solution from docker-compose that it solves the problem?

I tried this:

DOCKER_PATH=$(which docker) docker-compose up

volumes:
   - '/var/run/docker.sock:/var/run/docker.sock'
   - ${DOCKER_PATH}:/usr/bin/docker:ro

But I get the error:

ERROR: Invalid bind mount spec "59f5e4fa06257c16a046ae7e5163401349f1c0bb394c881bcdf557a2f544811c:$(which:rw": Invalid volume destination path: '$(which' mount path must be absolute.
+4
source share
1 answer

Does not work

DOCKER_PATH=$(which docker) docker-compose up

volumes:
   - '/var/run/docker.sock:/var/run/docker.sock'
   - ${DOCKER_PATH}:/usr/bin/docker:ro

Since variable substitution must be inside double quotes (single quotes don't work), e.g.

- "${DOCKER_PATH}:/usr/bin/docker:ro"

You can read more about this here: https://docs.docker.com/compose/compose-file/#variable-substitution

+1
source

Source: https://habr.com/ru/post/1661993/


All Articles