Skip to content

Commit 0293426

Browse files
authored
docker: Start containers with restart policy unless-stopped (#135)
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
1 parent d6f65d8 commit 0293426

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/container/docker/client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ func (c *Client) CreateContainer(
243243
CapAdd: permissionConfig.CapAdd,
244244
CapDrop: permissionConfig.CapDrop,
245245
SecurityOpt: permissionConfig.SecurityOpt,
246+
RestartPolicy: container.RestartPolicy{
247+
Name: "unless-stopped",
248+
},
246249
}
247250

248251
// Configure ports if options are provided
@@ -935,6 +938,11 @@ func compareHostConfig(existing *container.InspectResponse, desired *container.H
935938
return false
936939
}
937940

941+
// Compare restart policy
942+
if existing.HostConfig.RestartPolicy.Name != desired.RestartPolicy.Name {
943+
return false
944+
}
945+
938946
return true
939947
}
940948

0 commit comments

Comments
 (0)