Skip to content

Instantly share code, notes, and snippets.

@shaiguitar
Created August 31, 2017 22:27
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save shaiguitar/627d52ebc0c03af488477b5d636a8909 to your computer and use it in GitHub Desktop.
Save shaiguitar/627d52ebc0c03af488477b5d636a8909 to your computer and use it in GitHub Desktop.
Using docker compose to mount current working directory dynamically into the container
# mount volume PWD on host to /app in container.
shai@lappy ~/tmp/example-working-docker-compose-environment-vars [master *] ± % cat docker-compose.yml
version: "3"
services:
some_server:
...
volumes:
- $PWD:/app
# so using this from which/wherever you run this from, PWD should be updated and reflected within the container it runs in.
# /app within container should be reflected to be wherever you run this command from.
docker-compose -f ~/tmp/example-working-docker-compose-environment-vars/docker-compose.yml
@yuliangjin1985
Copy link

Great. Thank you.

@MoureDeervarse
Copy link

thanks

@jhanley-com
Copy link

Does not work when running compose from Windows

@Trung-DV
Copy link

Trung-DV commented Apr 7, 2024

@jhanley-com run docker compose config to validate

@Trung-DV
Copy link

Trung-DV commented Apr 8, 2024

@jhanley-com Hope this can help: https://stackoverflow.com/a/66268597, seems that PWD does not exist in Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment