Skip to content

Commit

Permalink
fix(docker): set up docker networks at proper stage
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgon committed Nov 4, 2024
1 parent 7e075f1 commit e7d266e
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions modules/system/apps/docker/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,14 @@ in
users.users."${config.mySystem.primaryUser}".extraGroups = [ "docker" ];
networking.firewall.interfaces."docker0".allowedUDPPorts = [ 53 ];

systemd.services.docker-network-prepare =
systemd.services.docker.postStart =
let
dockerBin = lib.getExe pkgs."${config.virtualisation.oci-containers.backend}";
in
{
script = ''
${dockerBin} network inspect ${cfg.network.private.name} >/dev/null 2>&1 || ${dockerBin} network create ${cfg.network.private.name} --subnet ${cfg.network.private.subnet} --internal
${dockerBin} network inspect ${cfg.network.public.name} >/dev/null 2>&1 || ${dockerBin} network create ${cfg.network.public.name} --subnet ${cfg.network.public.subnet}
'';
serviceConfig = {
Type = "oneshot";
User = "root";
};
};
lib.mkAfter ''
${dockerBin} network inspect ${cfg.network.private.name} >/dev/null 2>&1 || ${dockerBin} network create ${cfg.network.private.name} --subnet ${cfg.network.private.subnet} --internal
${dockerBin} network inspect ${cfg.network.public.name} >/dev/null 2>&1 || ${dockerBin} network create ${cfg.network.public.name} --subnet ${cfg.network.public.subnet}
'';

environment.persistence."${config.mySystem.impermanence.persistPath}" =
lib.mkIf config.mySystem.impermanence.enable
Expand Down

0 comments on commit e7d266e

Please sign in to comment.