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

Set hostname inside docker box #243

Closed
kim0 opened this issue Mar 28, 2013 · 11 comments
Closed

Set hostname inside docker box #243

kim0 opened this issue Mar 28, 2013 · 11 comments

Comments

@kim0
Copy link
Contributor

kim0 commented Mar 28, 2013

As a puppet user, I should be able to set the hostname inside the docker (box?) as seen by processes running inside it. I use hostnames to set puppet roles, thus this is quite important in my use case

Thanks

@jpetazzo
Copy link
Contributor

That should work already, thanks to the uts namespace.

Can you please describe what you were trying to do, what you were expecting, and what happened?

Thank you!

@shykes
Copy link
Contributor

shykes commented Mar 29, 2013

@kim0 would this be a good solution for you?

docker run -h MY_HOSTNAME /bin/sh -c 'my hostname is $(hostname)'

@kim0
Copy link
Contributor Author

kim0 commented Mar 29, 2013

Yes absolutely, I didn't look hard enough. Thanks folks

On Fri, Mar 29, 2013 at 3:13 AM, Solomon Hykes notifications@github.comwrote:

@kim0 https://github.com/kim0 would this be a good solution for you?

docker run -h MY_HOSTNAME /bin/sh -c 'my hostname is $(hostname)'


Reply to this email directly or view it on GitHubhttps://github.com//issues/243#issuecomment-15624414
.

@progrium
Copy link
Contributor

Perhaps this should be tied to container naming.

On Thu, Mar 28, 2013 at 6:29 PM, kim0 notifications@github.com wrote:

Yes absolutely, I didn't look hard enough. Thanks folks

On Fri, Mar 29, 2013 at 3:13 AM, Solomon Hykes notifications@github.comwrote:

@kim0 https://github.com/kim0 would this be a good solution for you?

docker run -h MY_HOSTNAME /bin/sh -c 'my hostname is $(hostname)'


Reply to this email directly or view it on GitHub<
https://github.com/dotcloud/docker/issues/243#issuecomment-15624414>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/243#issuecomment-15624809
.

Jeff Lindsay
http://progrium.com

@shykes
Copy link
Contributor

shykes commented Apr 1, 2013

See #299

@progrium
Copy link
Contributor

progrium commented Apr 1, 2013

It would be rad if you could then refer to containers by hostname instead
of ID. :D

On Mon, Apr 1, 2013 at 2:43 PM, Solomon Hykes notifications@github.comwrote:

See #299 #299


Reply to this email directly or view it on GitHubhttps://github.com//issues/243#issuecomment-15739222
.

Jeff Lindsay
http://progrium.com

@sa2ajj
Copy link
Contributor

sa2ajj commented Apr 1, 2013

@progrium, maybe you could open another issue and describe the scenario you envision?

My personal feeling is that referring to the container by the host name might be ambigous in certain scenarios...

@progrium
Copy link
Contributor

progrium commented Apr 1, 2013

That would really be up to you to make it ambiguous. You can always fall
back to ID. Anywhere you use ID, you should be able to use hostname. Or
some other alias. But since we have custom hostnames, we might as well use
that for naming?

On Mon, Apr 1, 2013 at 2:52 PM, Mikhail Sobolev notifications@github.comwrote:

@progrium https://github.com/progrium, maybe you could open another
issue and describe the scenario you envision?

My personal feeling is that referring to the container by the host name
might be ambigous in certain scenarios...


Reply to this email directly or view it on GitHubhttps://github.com//issues/243#issuecomment-15739655
.

Jeff Lindsay
http://progrium.com

@danmayer
Copy link

danmayer commented Oct 5, 2013

is there a reason this strips out anything with subdomains?

kr@utils:~/dockerfiles/graphite$ docker run -h 'utils.mysite.com' -i -t ubuntu /bin/bash
root@utils:/# echo $(hostname)
utils

@ghost
Copy link

ghost commented Oct 5, 2013

It sets the host and domain names:

$ docker run -h foo.bar.baz -i -t ubuntu bash
root@foo:/# hostname
foo
root@foo:/# hostname -d
bar.baz
root@foo:/# hostname -f
foo.bar.baz
root@foo:/#

@danmayer
Copy link

danmayer commented Oct 5, 2013

Awesome thanks a bunch, learning new things I am sure that was a pretty obvious fail on my part. ;)

rhvgoyal pushed a commit to rhvgoyal/moby that referenced this issue Jun 1, 2017
[1.12.6] BACKPORT: Handle containers with different network drivers
thaJeztah pushed a commit to thaJeztah/docker that referenced this issue Jun 18, 2019
[18.09 backport] Skip TestInfoAPIWarnings on remote daemons
dperny pushed a commit to dperny/docker that referenced this issue Oct 18, 2021
[master] sync with upstream moby master 6800954
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

6 participants