Compose: Docker Compose parses host paths for ENV substitution, but not container paths

Created on 1 Jul 2015  路  4Comments  路  Source: docker/compose

This comment in #551 indicates that the following syntax should work for passing SSH_AUTH_SOCK into a container:

volumes:
    - $SSH_AUTH_SOCK:$SSH_AUTH_SOCK
environment:
    - SSH_AUTH_SOCK

However, resolve_host_path in config.py does exactly as it's named, it resolves the host path but not the container path.

This means that the snippet pasted above results in a volume like this:

['/tmp/ssh-4NokVWqj63/agent.10499:$SSH_AUTH_SOCK']

Instead of resolve_host_paths/resolve_host_path, the functions should probably be resolve_path/resolve_paths and resolve both host and container paths.

kinbug

Most helpful comment

I do this by setting the container path to a fixed path. Since it's in a container, there's only going to be one user, so it doesn't really need to be dynamic/random.


volumes:
    - $SSH_AUTH_SOCK:/tmp/agent.sock
environment:
    - SSH_AUTH_SOCK=/tmp/agent.sock

I believe that's what was meant by the referenced comment.

All 4 comments

It looks like this is also noted in #1167. There's also #1377, but that seems to be a larger discussion. It seems like a small change, just run container_path through the same parsing as host_path.

I do this by setting the container path to a fixed path. Since it's in a container, there's only going to be one user, so it doesn't really need to be dynamic/random.


volumes:
    - $SSH_AUTH_SOCK:/tmp/agent.sock
environment:
    - SSH_AUTH_SOCK=/tmp/agent.sock

I believe that's what was meant by the referenced comment.

Ah ha! I hadn't seen that style before, but it makes sense, since you can volume mount a single file with different names. I'll use this for our current use case, but the commit still might be a handy thing to have.

Closed by #1633

Was this page helpful?
0 / 5 - 0 ratings