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
containers with extraModules in host #13852
Comments
Is your container declarative or imperative? It looks like you've mixed these two configuration schemes. When created as described in your steps to reproduce everything should be fine because your container will be assigned an IPv4 during creation. |
@hrdinka , i mix declarative and imperative. At first, i did imperative and it has IPv4 when i do
. But, i cannot connect to the internet, because my "imperative" way does not recognize my ethernet card. That's when i remember that i added extraModules to my host configuration.nix. So, I added these extraModules to the containers via "declarative" way, and suddenly, the IPv4 is missing and produce the above error even when i did not put the localAddress and hostAddress in my host configuration.nix. So, now the IPv4 is missing because i added the extraModules in declarative way via my host configuration.nix |
Looks like you've got several things mixed up here:
The reason why you didn't had network connectivity within your container is likely a different one. On a freshly created container you can examine your network interfaces with The problem is that your container is in a different subnet than your hosts wan and by default your host won't route between these two networks. If it does and your router is properly configured it will block all traffic from your container because it's not part of the routers subnet. First check if ip forwarding is enabled on your host
Next you can review ( Update: There is no need to enable ip forwarding manually if you are using nixos config for nat or routing. These options will do this automatically for you. |
Hi @hrdinka, thank you for your suggestion, i think i did had misunderstanding about how containers work. so in this case, if i do pure declarative configuration, i don't need to configure the configuration.nix on my containers? thanks, |
Yes that's how it works. When using imperative containers your containers function like completely independent machines and won't be bothered by your host at all. With declarative containers your containers are part of your hosts config. NixOS handles your host&containers as one entity and builds&updates these together. Both behaviors are nice to have and come in handy depending on your projects needs. Decide for on cause you can't mix them. |
I believe this issue can be closed. |
Basic info
To make sure that we are on the same page:
Describe your issue here
I create new containers called beHaskell with this configuration
when i tried to do
nix-channel --update
i cannot connect to the internet, i tried to ping google.com in my containers and it cannot connect.so, i add containers configuration in my host /etc/nixos/configuration.nix like this:
i add the kernelModules = [ "e1000e"], then
nixos-rebuild switch
in my host. It build perfectly and nothing happened. I can connect to my beHaskell container and donix-channel --update
andnixos-rebuild switch
the problem occurs when i tried to do nixos-container show-ip beHaskell from my host, the error says
/run/current-system/sw/bin/nixos-container: cannot get IP address
then i tried to add the following code:
to the container attribute in my host configuration.nix, and when i tried to do "nixos-rebuild switch" it got an error :
The option
containers.beHaskell.hostAddress' defined in<unknown-file>' does not exist.
Expected result
10.10.0.2
Actual result
/run/current-system/sw/bin/nixos-container: cannot get IP address
and after add the localAddress and hostAddress:
The option
containers.beHaskell.hostAddress' defined in<unknown-file>' does not exist.
Steps to reproduce
The text was updated successfully, but these errors were encountered: