Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an environment variable with the name of the current container #408

Closed
dsyer opened this issue Aug 13, 2014 · 5 comments
Closed

Comments

@dsyer
Copy link

dsyer commented Aug 13, 2014

I can see traces of it everywhere, e.g. in /etc/hosts:

172.17.0.198    848fdb642137
127.0.0.1   localhost
...
172.17.0.193    web_1
...

and

$ env | grep web
...
WEB_1_NAME=web_1
...

so fig has injected it in there somehow, but not in a very accessible way. It would be great to be able to discover that at runtime.

@dnephin
Copy link

dnephin commented Aug 14, 2014

CONTAINER_NAME=$(hostname) should give it to you. I'm not sure if there is a better way

@dsyer
Copy link
Author

dsyer commented Aug 14, 2014

I think I know what you are trying to do, but hostname is set to a dockerish hash identifier (the container?) - 848fdb642137 in the example above. So not very useful for inter process communication.

@dnephin
Copy link

dnephin commented Aug 14, 2014

I guess I didn't understand the issue, what is "the name of the current container" ?

@dsyer
Copy link
Author

dsyer commented Aug 14, 2014

In the example above it would be "web_1". Apologies if "name" is the wrong noun - it's not the hash id, so I didn't know what to call it. It's actually the hostname exposed via the docker link (I assume it is fig adding the "_1").

@dnephin
Copy link

dnephin commented Sep 1, 2015

Duplicate of #1503 which has a PR open for it, so closing this one.

@dnephin dnephin closed this as completed Sep 1, 2015
xulike666 pushed a commit to xulike666/compose that referenced this issue Jan 19, 2017
Point digest import to opencontainers/go-digest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants