Reputation: 41
I need to run the following commands in the docker-compose:
- '/var/run/docker.sock:/var/run/docker.sock'
- '$(which docker):$(which docker)'
I found a solution for such a format:
- ${DOCKER_PATH}:/usr/bin/docker:ro
But in my case, I need to run this format $(..):$(..),
Is there any simple solution from the docker-compose it solve 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 error:
ERROR: Invalid bind mount spec "59f5e4fa06257c16a046ae7e5163401349f1c0bb394c881bcdf557a2f544811c:$(which:rw": Invalid volume destination path: '$(which' mount path must be absolute.
Upvotes: 4
Views: 262
Reputation: 2819
The following doesn't work
DOCKER_PATH=$(which docker) docker-compose up
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
- ${DOCKER_PATH}:/usr/bin/docker:ro
Because variable substitution needs to be inside double quotes (single quotes wont work), like this
- "${DOCKER_PATH}:/usr/bin/docker:ro"
You can read more about it here: https://docs.docker.com/compose/compose-file/#variable-substitution
Upvotes: 1