Skip to content
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.

Windows + Git Bash: volume path woes #5

Closed
fvsch opened this issue Sep 29, 2016 · 2 comments
Closed

Windows + Git Bash: volume path woes #5

fvsch opened this issue Sep 29, 2016 · 2 comments

Comments

@fvsch
Copy link
Contributor

fvsch commented Sep 29, 2016

To follow up on issues we've discussed with @supasteev0, about user-configurable paths on Windows, we're using:

When trying to define Windows paths for volumes in docker-compose.config.sh and use them dynamically in docker-compose.yml, with this syntax:

  volumes:
    - "$DOCKER_WWW_ROOT:/var/www"

We're getting this error:

ERROR: for cli Cannot create container for service cli: Invalid volume spec "C": Invalid volume destination path: 'C' mount path must be absolute.

I set out to find how docker-compose resolves the config. In start.sh, I'm adding a "showconf" command:

    showconf)
        $DOCKER_COMPOSE --verbose config
        ;;

For this config:

  volumes:
    - 'd:/Dev/www:/var/www'
    # Both variables set to the values show above
    - "$DOCKER_WWW_ROOT:$DOCKER_WWW_DEST"
    # In Git Bash, that variable is, e.g.: /tmp/ssh-cJ59v8lPx0K4/agent.4640
    # (Knowing that Windows doesn't have a "/tmp" path, that's a virtual path of sorts.)
    - "$SSH_AUTH_SOCK:/ssh-agent"

Once resolved, the config is:

  volumes:
    - /d/Dev/www:/var/www:rw
    - /d/Dev/www:C:/Program Files/Git/var/www/
    - /c/Users/USERNA~1/AppData/Local/Temp/ssh-cJ59v8lPx0K4/agent.4640:/ssh-agent:rw

Lessons:

  • docker-compose adds the default ":rw" flag if another one (e.g. ":ro") was not set already.
  • 'd:/Dev/www' gets resolved to /d/Dev/www. Alright.
  • Apparently in Git Bash the /tmp directory is an alias for ~/AppData/Local/Temp
  • Finally, Git Bash resolves our $DOCKER_WWW_DEST var as C:/Program Files/Git/var/www/, which is a compatibility feature it has for other reasons. And that's the part that was breaking our config!

So if I change our config to:

  volumes:
    - "$DOCKER_WWW_ROOT:/var/www"

Everything works fine.

Maybe changing the frontend template to hardcode container-side paths would be enough to fix this?

@fvsch
Copy link
Contributor Author

fvsch commented Sep 30, 2016

(Just realized adding the showconf command was not necessary and I could just do ./stack.sh config.)

@supasteev0
Copy link

@fvsch frontend template has been updated with hardcoded /var/www path

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants