Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/konradmalik/darwin-docker
nix-darwin module to run docker
https://github.com/konradmalik/darwin-docker
docker docker-on-mac macos nix nix-darwin
Last synced: about 8 hours ago
JSON representation
nix-darwin module to run docker
- Host: GitHub
- URL: https://github.com/konradmalik/darwin-docker
- Owner: konradmalik
- License: mit
- Created: 2024-01-25T09:16:00.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-08-09T11:46:13.000Z (3 months ago)
- Last Synced: 2024-08-09T13:06:52.226Z (3 months ago)
- Topics: docker, docker-on-mac, macos, nix, nix-darwin
- Language: Nix
- Homepage:
- Size: 14.6 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Docker module for nix-darwin
## Important!
For some reason this does not work anymore for me. The VM does not start at all when I enable docker.
Maybe I'll fix it someday, but it's hard to debug. For now I just use [lima](https://github.com/lima-vm/lima) for docker on Mac and start it on-demand.## Before enable
You may need to enable to `linux-builder` without this addon first (`nix.linux-builder.enable = true`).
This is because you need some machine to build linux configuration on darwin.## Usage
Import the module to your configuration, then enable with:
```nix
# just an example
{ inputs, ... }:
{
imports = [
inputs.darwin-docker.darwinModules.docker
];virtualisation.docker = {
enable = true;
};
}
```Then rebuild your config, make sure `DOCKER_HOST` is set. If not set it manually:
```bash
export DOCKER_HOST="tcp://127.0.0.1:2375"
```then run:
```bash
$ docker info
```It should connect and print relevant info.
See the module code for more options.
Tip: if you have a NixOS config for docker, you should be able to do something like this:
- in linux.nix
```nix
{
virtualisation.docker = {
enable = true;
autoPrune = {
enable = true;
flags = [ "--all" ];
dates = "weekly";
};
};
}
```- in darwin.nix:
```nix
{ pkgs, inputs, ... }:
{
imports = [
inputs.darwin-docker.darwinModules.docker
];virtualisation.docker = {
enable = true;
config = import ./linux.nix;
};
}
```## Notes
- why? because if you're already using nix-darwin, then this VM will be very lightweight in terms of disk space and very fast to start
- this builds on top of `nix-builder` module and `darwin-builder` VM
- it runs as a daemon in the background
- docker is exposed on `tcp://127.0.0.1:2375` on the host system
- `DOCKER_HOST` env variable is set to the above address
- configuration/customization can be easilty done via `virtualisation.docker.config` - this gets directly passed to the underlying NixOS VM config as a module
- ssh access directly to the machine should be possible with: `sudo ssh linux-builder`