Created
March 5, 2018 20:26
-
-
Save zarelit/bcccf1af1094bf200f218d7f2ae5dbde to your computer and use it in GitHub Desktop.
nixos declarative containers in bridge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, pkgs, lib, ... }: | |
{ | |
# Other host options | |
## Containers | |
# Containers are bridged with the physical LAN adapter | |
networking.bridges.br0.interfaces = ["eth0"]; | |
# Example with gogs (VM name: projects) | |
containers.projects = { | |
autoStart = true; | |
config = | |
{ config, pkgs, ... }: | |
{ | |
# Other guest options | |
services.gogs = { | |
enable = true; | |
}; | |
networking.firewall = { | |
allowedTCPPorts = [ 3000 ]; # GOGS listen by default on port 3000 | |
# kludge to make GOGS working on port 80 without messing with users | |
# extraCommands = "iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000"; | |
}; | |
}; | |
privateNetwork = true; | |
hostBridge = "br0"; | |
localAddress = "192.168.1.25/24"; # Containers in bridge mode cannot have networking.useDHCP = true; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment