Skip to content

Commit

Permalink
add support for runtime and security_opt
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiksi committed Nov 29, 2023
1 parent 4c4d319 commit afbfd8d
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ Note: if the Compose service has a `container_name` set, then the systemd servic
sudo systemctl restart podman-myproject-myservice.service
```
#### Update a Container
1. Pull the latest image:
```
podman pull image
```
2. Restart the service:
```
sudo systemctl restart podman-myproject-myservice.service
```
#### `docker compose down`
By default, this will only remove networks.
Expand Down Expand Up @@ -190,6 +204,8 @@ If a feature is missing, please feel free to [create an issue](https://github.co
| [`extra_hosts`](https://docs.docker.com/compose/compose-file/05-services/#extra_hosts) | ✅ |
| [`sysctls`](https://docs.docker.com/compose/compose-file/05-services/#sysctls) | ✅ |
| [`shm_size`](https://docs.docker.com/compose/compose-file/05-services/#shm_size) | ✅ |
| [`runtime`](https://docs.docker.com/compose/compose-file/05-services/#runtime) | ✅ |
| [`security_opt`](https://docs.docker.com/compose/compose-file/05-services/#security_opt) | ✅ |
#### [`networks`](https://docs.docker.com/compose/compose-file/06-networks/)
Expand Down
6 changes: 6 additions & 0 deletions compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@ func (g *Generator) buildNixContainer(service types.ServiceConfig) (*NixContaine
for _, device := range service.Devices {
c.ExtraOptions = append(c.ExtraOptions, "--device="+device)
}
if service.Runtime != "" {
c.ExtraOptions = append(c.ExtraOptions, "--runtime="+service.Runtime)
}
for _, opt := range service.SecurityOpt {
c.ExtraOptions = append(c.ExtraOptions, "--security-opt="+opt)
}

// https://docs.docker.com/compose/compose-file/05-services/#extra_hosts
// https://docs.docker.com/engine/reference/commandline/run/#add-host
Expand Down
2 changes: 2 additions & 0 deletions testdata/TestDocker_EnvFilesOnly_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@
"--log-opt=max-file=3"
"--log-opt=max-size=10m"
"--network=container:sabnzbd"
"--runtime=nvidia"
"--security-opt=label=disable"
];
};
systemd.services."docker-traefik" = {
Expand Down
2 changes: 2 additions & 0 deletions testdata/TestDocker_RemoveVolumes_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@
"--log-opt=max-file=3"
"--log-opt=max-size=10m"
"--network=container:sabnzbd"
"--runtime=nvidia"
"--security-opt=label=disable"
];
};
systemd.services."docker-traefik" = {
Expand Down
2 changes: 2 additions & 0 deletions testdata/TestDocker_SystemdMount_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@
"--log-opt=max-file=3"
"--log-opt=max-size=10m"
"--network=container:sabnzbd"
"--runtime=nvidia"
"--security-opt=label=disable"
];
};
systemd.services."docker-traefik" = {
Expand Down
2 changes: 2 additions & 0 deletions testdata/TestDocker_WithProject_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@
"--log-opt=max-file=3"
"--log-opt=max-size=10m"
"--network=container:sabnzbd"
"--runtime=nvidia"
"--security-opt=label=disable"
];
};
systemd.services."docker-traefik" = {
Expand Down
2 changes: 2 additions & 0 deletions testdata/TestDocker_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@
"--log-opt=max-file=3"
"--log-opt=max-size=10m"
"--network=container:sabnzbd"
"--runtime=nvidia"
"--security-opt=label=disable"
];
};
systemd.services."docker-traefik" = {
Expand Down
2 changes: 2 additions & 0 deletions testdata/TestPodman_WithProject_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@
"--log-opt=max-file=3"
"--log-opt=max-size=10m"
"--network=container:sabnzbd"
"--runtime=nvidia"
"--security-opt=label=disable"
];
};
systemd.services."podman-traefik" = {
Expand Down
2 changes: 2 additions & 0 deletions testdata/TestPodman_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@
"--log-opt=max-file=3"
"--log-opt=max-size=10m"
"--network=container:sabnzbd"
"--runtime=nvidia"
"--security-opt=label=disable"
];
};
systemd.services."podman-traefik" = {
Expand Down
3 changes: 3 additions & 0 deletions testdata/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ services:
- "compose2nix.systemd.service.Restart=none"
- "compose2nix.systemd.unit.AllowIsolate=true"
network_mode: "container:sabnzbd"
runtime: nvidia
security_opt:
- label=disable
logging:
driver: "json-file"
options:
Expand Down

0 comments on commit afbfd8d

Please sign in to comment.