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.nix: Add options for named volumes and networks #64580
Conversation
@grahamc would you like to have a look? |
@GrahamcOfBorg test docker |
492372c
to
2966b65
Compare
I've added some I ran into this with |
I'm unsure about these abstractions being in |
I would also have a separate systemd unit and not as part of docker |
That seems over-engineered to me, but thanks for the review. |
I think it does not change a lot in terms of additonal complexity, but provides a separation between what is a basically systemd unit for docker and all our custom abstraction over it. The problem is that nixos is already bloated from my point of view, and especially nixpkgs and I'm not against additional abstraction, especially if it provides value to multiple users. Let's just keep it separated, so in the future it can be easier to refactor, does this makes sense? |
The other option I was considering is making it easier to run some I wrote this PR hoping to improve the nix wrappers around Docker, and I have some patches for the other module down here that I need to clean up for review too. I also realize that trying to make Docker be actually nix-compliant is a fool's errand, so maybe this entire PR is just misled. |
(I know @offlinehacker already gave some feedback, just wanting to officially delegate my opinion to him -- as @mkaito requested my review on IRC.) |
For compatibility, it's probably best to introduce something similar to I think it's bad if whether the docker daemon comes up depends on whether applying these new options fails, but I also think user services may need to depend on these volumes and networks being created, so I agree that it's best if they're handled in a separate systemd unit.
There's |
You can't delete used volumes either way. For example, We can create a custom helper image, but that seems like three kinds of overkill to me, and just adds unnecessary maintenance burden. Trying to make the Docker world deterministic is a bit of a fool's errand. Perhaps the best idea here is to either call it I have some patches to
Yeah, I saw |
Thank you for your contributions.
|
Motivation for this change
I was porting some
docker-compose
stuff todocker-containers.nix
and found the lack of declarative networks and volumes.Things done
services.docker.volumes = [ "one" "two" ];
services.docker.networks.foo = {};
A few notes:
docker.service
postStart
, since I didn't want to tie it to any particular way to run docker containers, plus these entities are "docker-global", and so I think they fit well in thedocker
module.grep
to do a set complement, which is nice.nix-build -A nixosTests.docker
passes on my computer.sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)