- 1 year ago
Use relative volume path in docker-compose in Windows cmd
Comment
1 / 1
To use a relative volume path in docker-compose
on Windows cmd, you can use the %cd%
environment variable to refer to the current working directory of the command prompt. Here's an example of how to do this:
yamlversion: '3.9'
services:
myservice:
image: myimage:latest
volumes:
- %cd%/mydata:/data
In this example, the volumes
section specifies a relative path using %cd%
. This will be expanded to the full path of the current working directory followed by /mydata
. The mydata
folder will be mounted inside the container at /data
.
Note that this approach works for Windows cmd, but may not work for other command-line interfaces or operating systems. In those cases, you may need to use a different approach or modify the syntax accordingly.