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

hostname is always overwritten by container id in container when using --network=host #2694

Closed
shilaidun opened this issue Dec 11, 2023 · 1 comment · Fixed by #3344
Closed
Labels
bug Something isn't working

Comments

@shilaidun
Copy link

Description

Restart the container every time , hostname is always overwritten by container id in container when using --network=host,but the hostname in the container will change at any time, after restarting the container it changes to the container id AGAIN!

Steps to reproduce the issue

1.nerdctl run --network=host -v /etc/resolv.conf:/etc/resolv.conf -v /etc/hosts:/etc/hosts -v /etc/hostname:/etc/hostname --privileged=true images:v1.0.0 --name=test
2.nerdctl exec -it test bash
3.hostname : it shows container id a7e60e651786
4.echo 'myhost' > /etc/hostname && hostname 'myhost'
5.restart the container
6.nerdctl exec -it test bash
7.hostname: it shows container id a7e60e651786 AGAIN! not named 'myhost'

Describe the results you received and expected

hostname : it shows myhost

What version of nerdctl are you using?

1.7.0

Are you using a variant of nerdctl? (e.g., Rancher Desktop)

None

Host information

No response

@shilaidun shilaidun added the kind/unconfirmed-bug-claim Unconfirmed bug claim label Dec 11, 2023
@AkihiroSuda AkihiroSuda added bug Something isn't working and removed kind/unconfirmed-bug-claim Unconfirmed bug claim labels Dec 11, 2023
@apostasie
Copy link
Contributor

  1. Restarting the container will reset the hostname as well with Docker, so, it is unlikely we would change the behavior of nerdctl.
  2. the hostname in network=host should be by default the hostname of the host (and not the container id) - this part is definitely a bug
  3. if you just want to override the hostname of a container, why not do nerdctl run -ti --hostname hostnamelalafoo debian?

@shilaidun ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants