Hey, pretty new to NixOS. Been using it for about 2 weeks on my NUC, deploying to it via NixOps on my Mac using a local build machine in Docker.
I am porting over all of my services that I ran on Ubuntu via docker-compose to Nix and decided to switch to Podman during this transition. Everything is working great thus far, but I am running in to a small hurdle when configuring multiple services that need to talk to each other.
In docker-compose, this is easy because compose will map all the containers and make them accessible by DNS such as http://influxdb:8086. My solution in Podman is to create a Pod and put all of my related containers in that Pod so that they can communicate using http://localhost:8086.
Additionally, I can map ports to the entire Pod to make the service accessible outside Podman. This works and is great, but I have not found a declarative way to create this Pod using the Nix config.
Has anyone had any luck achieving this?
influxdb.nix
{
autoStart = true;
image = "influxdb:1.8.4";
environment = {
"INFLUXDB_REPORTING_DISABLED" = "true";
"INFLUXDB_DATA_QUERY_LOG_ENABLED" = "true";
};
extraOptions = [ "--pod=elk" ];
volumes = [
"influxdb:/var/lib/influxdb"
];
}
grafana.nix
{
autoStart = true;
image = "grafana/grafana:7.4.1";
dependsOn = [ "influxdb" ];
extraOptions = [ "--pod=elk" ];
volumes = [ "grafana:/var/lib/grafana" ];
}
configuration.nix
virtualisation = {
oci-containers = {
backend = "podman";
containers = {
grafana = import ./containers/grafana.nix;
influxdb = import ./containers/influxdb.nix;
};
};
};