Repository: aksiksi/compose2nix (go)

Issue:
Bug: volume names aren't properly outputted
Hi, it's me again with another bug report

Let's say we have the following compose file:
```yaml
name: "example"

volumes:
  test:
  test2:
    name: other_test2
  example_test3:

services:
  app:
    image: hello-world
    volumes:
      - test:/test
      - test2:/test2
      - example_test3:/test3
```

The resulting nix file will contain:
```nix
virtualisation.oci-containers.containers."example-app".volumes = [
      "example_test3:/test3:rw"
      "test:/test:rw"
      "test2:/test2:rw"
];
```

This is incorrect.  
The names of the volumes should be always prefixed with the project name, unless the name property is given (which is an enhancement I understand isn't implemented). In this case, the container will not be able to be created unless the name of the container is set to `<project_name>_<name>`. 



Pull request description:
Use full volume name in container config
Fixes #26 

Patch:
diff --git a/compose.go b/compose.go
index 7e14b3d..bb0f265 100644
--- a/compose.go
+++ b/compose.go
@@ -237,8 +237,14 @@ func (g *Generator) buildNixContainer(service types.ServiceConfig, networkMap ma
 
 	for _, v := range service.Volumes {
 		if volume, ok := volumeMap[v.Source]; ok {
-			// Use the actual volume name.
-			c.Volumes[volume.Name] = v.String()
+			// Replace the Compose volume name with the actual Docker volume
+			// name (i.e., potentially prefixed with project).
+			//
+			// This is what we'll use to refer to the volume in the generated
+			// container config.
+			volumeParts := strings.Split(v.String(), ":")
+			volumeParts[0] = volume.Name
+			c.Volumes[volume.Name] = strings.Join(volumeParts, ":")
 			if !volume.External {
 				// Add systemd dependencies on volume(s).
 				c.SystemdConfig.Unit.After = append(c.SystemdConfig.Unit.After, g.volumeNameToService(volume.Name))


Test patch:
diff --git a/nixos-test/docker-compose.nix b/nixos-test/docker-compose.nix
index e34251c..24a3e7b 100644
--- a/nixos-test/docker-compose.nix
+++ b/nixos-test/docker-compose.nix
@@ -62,6 +62,7 @@
     };
     volumes = [
       "/var/volumes/service-b:/config:rw"
+      "myproject_books:/books:rw"
       "storage:/storage:rw"
     ];
     dependsOn = [
@@ -87,10 +88,12 @@
     };
     after = [
       "docker-network-myproject_something.service"
+      "docker-volume-myproject_books.service"
       "docker-volume-storage.service"
     ];
     requires = [
       "docker-network-myproject_something.service"
+      "docker-volume-myproject_books.service"
       "docker-volume-storage.service"
     ];
     partOf = [
@@ -136,6 +139,21 @@
   };
 
   # Volumes
+  systemd.services."docker-volume-myproject_books" = {
+    path = [ pkgs.docker ];
+    serviceConfig = {
+      Type = "oneshot";
+      RemainAfterExit = true;
+    };
+    unitConfig.RequiresMountsFor = [
+      "/mnt/media/Books"
+    ];
+    script = ''
+      docker volume inspect myproject_books || docker volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+    '';
+    partOf = [ "docker-compose-myproject-root.target" ];
+    wantedBy = [ "docker-compose-myproject-root.target" ];
+  };
   systemd.services."docker-volume-storage" = {
     path = [ pkgs.docker ];
     serviceConfig = {
diff --git a/nixos-test/docker-compose.yml b/nixos-test/docker-compose.yml
index c83323a..885f277 100644
--- a/nixos-test/docker-compose.yml
+++ b/nixos-test/docker-compose.yml
@@ -24,6 +24,7 @@ services:
     volumes:
       - /var/volumes/service-b:/config
       - storage:/storage
+      - books:/books
     labels:
       - "compose2nix.systemd.unit.AllowIsolate=no"
       - "compose2nix.systemd.service.RuntimeMaxSec=360"
@@ -52,3 +53,9 @@ volumes:
       type: none
       device: /mnt/media
       o: bind
+  books:
+    driver_opts:
+      type: none
+      device: /mnt/media/Books
+      o: bind
+
diff --git a/nixos-test/podman-compose.nix b/nixos-test/podman-compose.nix
index 50eb19f..6997cf9 100644
--- a/nixos-test/podman-compose.nix
+++ b/nixos-test/podman-compose.nix
@@ -64,6 +64,7 @@
     };
     volumes = [
       "/var/volumes/service-b:/config:rw"
+      "myproject_books:/books:rw"
       "storage:/storage:rw"
     ];
     dependsOn = [
@@ -89,10 +90,12 @@
     };
     after = [
       "podman-network-myproject_something.service"
+      "podman-volume-myproject_books.service"
       "podman-volume-storage.service"
     ];
     requires = [
       "podman-network-myproject_something.service"
+      "podman-volume-myproject_books.service"
       "podman-volume-storage.service"
     ];
     partOf = [
@@ -138,6 +141,21 @@
   };
 
   # Volumes
+  systemd.services."podman-volume-myproject_books" = {
+    path = [ pkgs.podman ];
+    serviceConfig = {
+      Type = "oneshot";
+      RemainAfterExit = true;
+    };
+    unitConfig.RequiresMountsFor = [
+      "/mnt/media/Books"
+    ];
+    script = ''
+      podman volume inspect myproject_books || podman volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+    '';
+    partOf = [ "podman-compose-myproject-root.target" ];
+    wantedBy = [ "podman-compose-myproject-root.target" ];
+  };
   systemd.services."podman-volume-storage" = {
     path = [ pkgs.podman ];
     serviceConfig = {
diff --git a/testdata/TestBasic.docker.nix b/testdata/TestBasic.docker.nix
index 1a2c9ca..5edbe4e 100644
--- a/testdata/TestBasic.docker.nix
+++ b/testdata/TestBasic.docker.nix
@@ -18,7 +18,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -56,10 +56,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     requires = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     partOf = [
       "docker-compose-myproject-root.target"
@@ -337,14 +337,14 @@
   };
 
   # Volumes
-  systemd.services."docker-volume-books" = {
+  systemd.services."docker-volume-myproject_books" = {
     path = [ pkgs.docker ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      docker volume inspect books || docker volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      docker volume inspect myproject_books || docker volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "docker-compose-myproject-root.target" ];
     wantedBy = [ "docker-compose-myproject-root.target" ];
diff --git a/testdata/TestBasic.podman.nix b/testdata/TestBasic.podman.nix
index 3bcd2cd..5139d40 100644
--- a/testdata/TestBasic.podman.nix
+++ b/testdata/TestBasic.podman.nix
@@ -23,7 +23,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -59,10 +59,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     requires = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     partOf = [
       "podman-compose-myproject-root.target"
@@ -332,14 +332,14 @@
   };
 
   # Volumes
-  systemd.services."podman-volume-books" = {
+  systemd.services."podman-volume-myproject_books" = {
     path = [ pkgs.podman ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      podman volume inspect books || podman volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      podman volume inspect myproject_books || podman volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "podman-compose-myproject-root.target" ];
     wantedBy = [ "podman-compose-myproject-root.target" ];
diff --git a/testdata/TestEnvFilesOnly.docker.nix b/testdata/TestEnvFilesOnly.docker.nix
index bb2847c..4c064b6 100644
--- a/testdata/TestEnvFilesOnly.docker.nix
+++ b/testdata/TestEnvFilesOnly.docker.nix
@@ -16,7 +16,7 @@
     ];
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -55,10 +55,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     requires = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     partOf = [
       "docker-compose-myproject-root.target"
@@ -316,14 +316,14 @@
   };
 
   # Volumes
-  systemd.services."docker-volume-books" = {
+  systemd.services."docker-volume-myproject_books" = {
     path = [ pkgs.docker ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      docker volume inspect books || docker volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      docker volume inspect myproject_books || docker volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "docker-compose-myproject-root.target" ];
     wantedBy = [ "docker-compose-myproject-root.target" ];
diff --git a/testdata/TestEnvFilesOnly.podman.nix b/testdata/TestEnvFilesOnly.podman.nix
index 880958c..a1832d9 100644
--- a/testdata/TestEnvFilesOnly.podman.nix
+++ b/testdata/TestEnvFilesOnly.podman.nix
@@ -21,7 +21,7 @@
     ];
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -58,10 +58,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     requires = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     partOf = [
       "podman-compose-myproject-root.target"
@@ -311,14 +311,14 @@
   };
 
   # Volumes
-  systemd.services."podman-volume-books" = {
+  systemd.services."podman-volume-myproject_books" = {
     path = [ pkgs.podman ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      podman volume inspect books || podman volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      podman volume inspect myproject_books || podman volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "podman-compose-myproject-root.target" ];
     wantedBy = [ "podman-compose-myproject-root.target" ];
diff --git a/testdata/TestExternalNetworksAndVolumes.docker.nix b/testdata/TestExternalNetworksAndVolumes.docker.nix
index c5ae255..f0889a7 100644
--- a/testdata/TestExternalNetworksAndVolumes.docker.nix
+++ b/testdata/TestExternalNetworksAndVolumes.docker.nix
@@ -12,7 +12,7 @@
   virtualisation.oci-containers.containers."traefik" = {
     image = "docker.io/library/traefik";
     volumes = [
-      "test1:/test1:rw"
+      "myproject_test1:/test1:rw"
       "test2:/test2:rw"
     ];
     ports = [
diff --git a/testdata/TestExternalNetworksAndVolumes.podman.nix b/testdata/TestExternalNetworksAndVolumes.podman.nix
index 271161b..ab7ba91 100644
--- a/testdata/TestExternalNetworksAndVolumes.podman.nix
+++ b/testdata/TestExternalNetworksAndVolumes.podman.nix
@@ -17,7 +17,7 @@
   virtualisation.oci-containers.containers."traefik" = {
     image = "docker.io/library/traefik";
     volumes = [
-      "test1:/test1:rw"
+      "myproject_test1:/test1:rw"
       "test2:/test2:rw"
     ];
     ports = [
diff --git a/testdata/TestNetworkAndVolumeNames.docker.nix b/testdata/TestNetworkAndVolumeNames.docker.nix
index 6ac0e68..024bda3 100644
--- a/testdata/TestNetworkAndVolumeNames.docker.nix
+++ b/testdata/TestNetworkAndVolumeNames.docker.nix
@@ -12,8 +12,8 @@
   virtualisation.oci-containers.containers."traefik" = {
     image = "docker.io/library/traefik";
     volumes = [
-      "test2:/test2:rw"
-      "test3:/test3:rw"
+      "my-volume:/test2:rw"
+      "myproject_test3:/test3:rw"
       "test1:/test1:rw"
     ];
     ports = [
diff --git a/testdata/TestNetworkAndVolumeNames.podman.nix b/testdata/TestNetworkAndVolumeNames.podman.nix
index 695cadb..7d85f33 100644
--- a/testdata/TestNetworkAndVolumeNames.podman.nix
+++ b/testdata/TestNetworkAndVolumeNames.podman.nix
@@ -17,8 +17,8 @@
   virtualisation.oci-containers.containers."traefik" = {
     image = "docker.io/library/traefik";
     volumes = [
-      "test2:/test2:rw"
-      "test3:/test3:rw"
+      "my-volume:/test2:rw"
+      "myproject_test3:/test3:rw"
       "test1:/test1:rw"
     ];
     ports = [
diff --git a/testdata/TestNoWriteNixSetup.docker.nix b/testdata/TestNoWriteNixSetup.docker.nix
index 010c6ad..6392257 100644
--- a/testdata/TestNoWriteNixSetup.docker.nix
+++ b/testdata/TestNoWriteNixSetup.docker.nix
@@ -12,7 +12,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -51,10 +51,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     requires = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     partOf = [
       "docker-compose-myproject-root.target"
@@ -336,14 +336,14 @@
   };
 
   # Volumes
-  systemd.services."docker-volume-books" = {
+  systemd.services."docker-volume-myproject_books" = {
     path = [ pkgs.docker ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      docker volume inspect books || docker volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      docker volume inspect myproject_books || docker volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "docker-compose-myproject-root.target" ];
     wantedBy = [ "docker-compose-myproject-root.target" ];
diff --git a/testdata/TestNoWriteNixSetup.podman.nix b/testdata/TestNoWriteNixSetup.podman.nix
index e82ed3a..e950065 100644
--- a/testdata/TestNoWriteNixSetup.podman.nix
+++ b/testdata/TestNoWriteNixSetup.podman.nix
@@ -12,7 +12,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -49,10 +49,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     requires = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     partOf = [
       "podman-compose-myproject-root.target"
@@ -326,14 +326,14 @@
   };
 
   # Volumes
-  systemd.services."podman-volume-books" = {
+  systemd.services."podman-volume-myproject_books" = {
     path = [ pkgs.podman ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      podman volume inspect books || podman volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      podman volume inspect myproject_books || podman volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "podman-compose-myproject-root.target" ];
     wantedBy = [ "podman-compose-myproject-root.target" ];
diff --git a/testdata/TestOverrideSystemdStopTimeout.docker.nix b/testdata/TestOverrideSystemdStopTimeout.docker.nix
index f4f856e..f18f656 100644
--- a/testdata/TestOverrideSystemdStopTimeout.docker.nix
+++ b/testdata/TestOverrideSystemdStopTimeout.docker.nix
@@ -18,7 +18,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -58,10 +58,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     requires = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     partOf = [
       "docker-compose-myproject-root.target"
@@ -347,14 +347,14 @@
   };
 
   # Volumes
-  systemd.services."docker-volume-books" = {
+  systemd.services."docker-volume-myproject_books" = {
     path = [ pkgs.docker ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      docker volume inspect books || docker volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      docker volume inspect myproject_books || docker volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "docker-compose-myproject-root.target" ];
     wantedBy = [ "docker-compose-myproject-root.target" ];
diff --git a/testdata/TestOverrideSystemdStopTimeout.podman.nix b/testdata/TestOverrideSystemdStopTimeout.podman.nix
index b8d2d00..c3ebe8c 100644
--- a/testdata/TestOverrideSystemdStopTimeout.podman.nix
+++ b/testdata/TestOverrideSystemdStopTimeout.podman.nix
@@ -23,7 +23,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -61,10 +61,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     requires = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     partOf = [
       "podman-compose-myproject-root.target"
@@ -342,14 +342,14 @@
   };
 
   # Volumes
-  systemd.services."podman-volume-books" = {
+  systemd.services."podman-volume-myproject_books" = {
     path = [ pkgs.podman ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      podman volume inspect books || podman volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      podman volume inspect myproject_books || podman volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "podman-compose-myproject-root.target" ];
     wantedBy = [ "podman-compose-myproject-root.target" ];
diff --git a/testdata/TestProject.docker.nix b/testdata/TestProject.docker.nix
index a50133c..d8c4de6 100644
--- a/testdata/TestProject.docker.nix
+++ b/testdata/TestProject.docker.nix
@@ -18,7 +18,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -57,10 +57,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     requires = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     partOf = [
       "docker-compose-myproject-root.target"
@@ -342,14 +342,14 @@
   };
 
   # Volumes
-  systemd.services."docker-volume-books" = {
+  systemd.services."docker-volume-myproject_books" = {
     path = [ pkgs.docker ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      docker volume inspect books || docker volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      docker volume inspect myproject_books || docker volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "docker-compose-myproject-root.target" ];
     wantedBy = [ "docker-compose-myproject-root.target" ];
diff --git a/testdata/TestProject.podman.nix b/testdata/TestProject.podman.nix
index 20820e2..f343c38 100644
--- a/testdata/TestProject.podman.nix
+++ b/testdata/TestProject.podman.nix
@@ -23,7 +23,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -60,10 +60,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     requires = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     partOf = [
       "podman-compose-myproject-root.target"
@@ -337,14 +337,14 @@
   };
 
   # Volumes
-  systemd.services."podman-volume-books" = {
+  systemd.services."podman-volume-myproject_books" = {
     path = [ pkgs.podman ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      podman volume inspect books || podman volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      podman volume inspect myproject_books || podman volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "podman-compose-myproject-root.target" ];
     wantedBy = [ "podman-compose-myproject-root.target" ];
diff --git a/testdata/TestRelativeServiceVolumes.docker.nix b/testdata/TestRelativeServiceVolumes.docker.nix
index c18c33e..c7237a0 100644
--- a/testdata/TestRelativeServiceVolumes.docker.nix
+++ b/testdata/TestRelativeServiceVolumes.docker.nix
@@ -16,8 +16,8 @@
       "/my/def/xyz:/xyz:rw"
       "/my/root/abc:/abc:rw"
       "/some/abc:/some/abc:rw"
-      "test2:/test2:rw"
-      "test3:/test3:rw"
+      "my-volume:/test2:rw"
+      "myproject_test3:/test3:rw"
       "test1:/test1:rw"
     ];
     log-driver = "journald";
diff --git a/testdata/TestRelativeServiceVolumes.podman.nix b/testdata/TestRelativeServiceVolumes.podman.nix
index 6068fa3..29d88f8 100644
--- a/testdata/TestRelativeServiceVolumes.podman.nix
+++ b/testdata/TestRelativeServiceVolumes.podman.nix
@@ -21,8 +21,8 @@
       "/my/def/xyz:/xyz:rw"
       "/my/root/abc:/abc:rw"
       "/some/abc:/some/abc:rw"
-      "test2:/test2:rw"
-      "test3:/test3:rw"
+      "my-volume:/test2:rw"
+      "myproject_test3:/test3:rw"
       "test1:/test1:rw"
     ];
     log-driver = "journald";
diff --git a/testdata/TestRemoveVolumes.docker.nix b/testdata/TestRemoveVolumes.docker.nix
index 251907a..6162746 100644
--- a/testdata/TestRemoveVolumes.docker.nix
+++ b/testdata/TestRemoveVolumes.docker.nix
@@ -18,7 +18,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -57,10 +57,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     requires = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     partOf = [
       "docker-compose-myproject-root.target"
@@ -342,15 +342,15 @@
   };
 
   # Volumes
-  systemd.services."docker-volume-books" = {
+  systemd.services."docker-volume-myproject_books" = {
     path = [ pkgs.docker ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
-      ExecStop = "${pkgs.docker}/bin/docker volume rm -f books";
+      ExecStop = "${pkgs.docker}/bin/docker volume rm -f myproject_books";
     };
     script = ''
-      docker volume inspect books || docker volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      docker volume inspect myproject_books || docker volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "docker-compose-myproject-root.target" ];
     wantedBy = [ "docker-compose-myproject-root.target" ];
diff --git a/testdata/TestRemoveVolumes.podman.nix b/testdata/TestRemoveVolumes.podman.nix
index 1c1533e..028d5d2 100644
--- a/testdata/TestRemoveVolumes.podman.nix
+++ b/testdata/TestRemoveVolumes.podman.nix
@@ -23,7 +23,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -60,10 +60,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     requires = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     partOf = [
       "podman-compose-myproject-root.target"
@@ -337,15 +337,15 @@
   };
 
   # Volumes
-  systemd.services."podman-volume-books" = {
+  systemd.services."podman-volume-myproject_books" = {
     path = [ pkgs.podman ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
-      ExecStop = "${pkgs.podman}/bin/podman volume rm -f books";
+      ExecStop = "${pkgs.podman}/bin/podman volume rm -f myproject_books";
     };
     script = ''
-      podman volume inspect books || podman volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      podman volume inspect myproject_books || podman volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "podman-compose-myproject-root.target" ];
     wantedBy = [ "podman-compose-myproject-root.target" ];
diff --git a/testdata/TestSystemdMount.docker.nix b/testdata/TestSystemdMount.docker.nix
index ed6f6aa..86d0100 100644
--- a/testdata/TestSystemdMount.docker.nix
+++ b/testdata/TestSystemdMount.docker.nix
@@ -18,7 +18,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -57,10 +57,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     requires = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     partOf = [
       "docker-compose-myproject-root.target"
@@ -360,7 +360,7 @@
   };
 
   # Volumes
-  systemd.services."docker-volume-books" = {
+  systemd.services."docker-volume-myproject_books" = {
     path = [ pkgs.docker ];
     serviceConfig = {
       Type = "oneshot";
@@ -370,7 +370,7 @@
       "/mnt/media/Books"
     ];
     script = ''
-      docker volume inspect books || docker volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      docker volume inspect myproject_books || docker volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "docker-compose-myproject-root.target" ];
     wantedBy = [ "docker-compose-myproject-root.target" ];
diff --git a/testdata/TestSystemdMount.podman.nix b/testdata/TestSystemdMount.podman.nix
index b55fa95..9082abf 100644
--- a/testdata/TestSystemdMount.podman.nix
+++ b/testdata/TestSystemdMount.podman.nix
@@ -23,7 +23,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -60,10 +60,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     requires = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     partOf = [
       "podman-compose-myproject-root.target"
@@ -355,7 +355,7 @@
   };
 
   # Volumes
-  systemd.services."podman-volume-books" = {
+  systemd.services."podman-volume-myproject_books" = {
     path = [ pkgs.podman ];
     serviceConfig = {
       Type = "oneshot";
@@ -365,7 +365,7 @@
       "/mnt/media/Books"
     ];
     script = ''
-      podman volume inspect books || podman volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      podman volume inspect myproject_books || podman volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "podman-compose-myproject-root.target" ];
     wantedBy = [ "podman-compose-myproject-root.target" ];
diff --git a/testdata/TestUpheldBy.docker.nix b/testdata/TestUpheldBy.docker.nix
index 8ca7dcf..43817c9 100644
--- a/testdata/TestUpheldBy.docker.nix
+++ b/testdata/TestUpheldBy.docker.nix
@@ -18,7 +18,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -57,10 +57,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     requires = [
-      "docker-volume-books.service"
+      "docker-volume-myproject_books.service"
     ];
     partOf = [
       "docker-compose-myproject-root.target"
@@ -351,14 +351,14 @@
   };
 
   # Volumes
-  systemd.services."docker-volume-books" = {
+  systemd.services."docker-volume-myproject_books" = {
     path = [ pkgs.docker ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      docker volume inspect books || docker volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      docker volume inspect myproject_books || docker volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "docker-compose-myproject-root.target" ];
     wantedBy = [ "docker-compose-myproject-root.target" ];
diff --git a/testdata/TestUpheldBy.podman.nix b/testdata/TestUpheldBy.podman.nix
index 948c509..a6edadb 100644
--- a/testdata/TestUpheldBy.podman.nix
+++ b/testdata/TestUpheldBy.podman.nix
@@ -23,7 +23,7 @@
     };
     volumes = [
       "/var/volumes/jellyseerr:/app/config:rw"
-      "books:/books:rw"
+      "myproject_books:/books:rw"
     ];
     cmd = [ "ls" "-la" "/" ];
     labels = {
@@ -60,10 +60,10 @@
       StartLimitIntervalSec = lib.mkOverride 500 120;
     };
     after = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     requires = [
-      "podman-volume-books.service"
+      "podman-volume-myproject_books.service"
     ];
     partOf = [
       "podman-compose-myproject-root.target"
@@ -346,14 +346,14 @@
   };
 
   # Volumes
-  systemd.services."podman-volume-books" = {
+  systemd.services."podman-volume-myproject_books" = {
     path = [ pkgs.podman ];
     serviceConfig = {
       Type = "oneshot";
       RemainAfterExit = true;
     };
     script = ''
-      podman volume inspect books || podman volume create books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
+      podman volume inspect myproject_books || podman volume create myproject_books --opt=device=/mnt/media/Books --opt=o=bind --opt=type=none
     '';
     partOf = [ "podman-compose-myproject-root.target" ];
     wantedBy = [ "podman-compose-myproject-root.target" ];
diff --git a/testdata/compose.yml b/testdata/compose.yml
index e96f002..ba27ad0 100644
--- a/testdata/compose.yml
+++ b/testdata/compose.yml
@@ -217,7 +217,6 @@ volumes:
       device: /mnt/media
       o: bind
   books:
-    name: books
     driver_opts:
       type: none
       device: /mnt/media/Books