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

docker run --add-host=NAME:host-gateway does not work #211124

Closed
yrashk opened this issue Jan 16, 2023 · 9 comments
Closed

docker run --add-host=NAME:host-gateway does not work #211124

yrashk opened this issue Jan 16, 2023 · 9 comments

Comments

@yrashk
Copy link
Contributor

yrashk commented Jan 16, 2023

Describe the bug

When trying to use the add-host feature from Docker, I get an nil entry in /etc/hosts inside of the container

Steps To Reproduce

Steps to reproduce the behavior:

  1. docker run -ti --add-host=test:host-gateway ubuntu:latest
  2. cat /etc/hosts
  3. It will contain
<nil>    test

Expected behavior

/etc/hosts should contain a mapping between host's IP and test

Notify maintainers

@offline @tailhook @vdemeester @periklis @mikroskeem @maxeaubrey

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.86, NixOS, 22.11 (Raccoon), 22.11.1421.e9ade2c8240`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.1`
 - channels(root): `"nixos-22.11.1421.e9ade2c8240"`
 - channels(yrashk): `"nixos-unstable-23.05pre439706.9813adc7f7c, release-22.11.tar.gz-22.11"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos
@mikroskeem
Copy link
Member

This sounds like upstream bug?

@yrashk
Copy link
Contributor Author

yrashk commented Jan 16, 2023

I have it working on Ubuntu, macOS, etc. That's what I thought it may be something NixOS specific, but I can't put my finger on it just yet.

@NateWright
Copy link
Contributor

I am also having this issue.

@mikroskeem
Copy link
Member

Does this issue still appear?

Built a system using nixos-22.11 channel (7dc71ae), Docker version 20.10.21, and I couldn't reproduce this:

[root@docker-playground:~]# docker run --rm -ti --add-host=test:host-gateway ubuntu:latest
root@f5913104e560:/# cat /etc/hosts
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
ff00::0	ip6-mcastprefix
ff02::1	ip6-allnodes
ff02::2	ip6-allrouters
172.17.0.1	test
172.17.0.2	f5913104e560

@NateWright
Copy link
Contributor

I am running the same versions and do see test mapped in. I can ping test but I cannot curl a website running on the host.

@mikroskeem
Copy link
Member

Do you have firewall enabled but Docker interface not added into networking.firewall.trustedInterfaces?

@NateWright
Copy link
Contributor

That does fix the issue. Thank you

@mikroskeem
Copy link
Member

I suppose that this problem has disappeared and issue can now be closed.

@Naim-Bijapure
Copy link

I have faced this issue.
this is a firewall-related issue. if anyone facing this issue you can disable the firewall.
networking.firewall.enable = false; ( not a good practice :) )

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

No branches or pull requests

4 participants