From 04647ea9d08d0a8e9e5f75791899b4bec20e85bb Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Tue, 27 Jul 2021 13:33:23 -0500 Subject: [PATCH] CAPD: set container restartPolicy to unless-stopped If the docker engine is restarted, either through a service restart or a full system reboot, the containers created by CAPD are left in a stopped state. This adds the restartPolicy setting to the Docker container creation so that containers will be automatically restarted on service restart unless the user has explicitly stopped the container prior to the restart. Signed-off-by: Sean McGinnis --- test/infrastructure/container/docker.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/infrastructure/container/docker.go b/test/infrastructure/container/docker.go index 2e5b57cf7865..3b632b69eca3 100644 --- a/test/infrastructure/container/docker.go +++ b/test/infrastructure/container/docker.go @@ -383,11 +383,12 @@ func (d *docker) RunContainer(ctx context.Context, runConfig *RunContainerInput, // privileges, but this flag also changes some mounts that are necessary // including some ones docker would otherwise do by default. // for now this is what we want. in the future we may revisit this. - Privileged: true, - SecurityOpt: []string{"seccomp=unconfined"}, // ignore seccomp - NetworkMode: dockercontainer.NetworkMode(runConfig.Network), - Tmpfs: runConfig.Tmpfs, - PortBindings: nat.PortMap{}, + Privileged: true, + SecurityOpt: []string{"seccomp=unconfined"}, // ignore seccomp + NetworkMode: dockercontainer.NetworkMode(runConfig.Network), + Tmpfs: runConfig.Tmpfs, + PortBindings: nat.PortMap{}, + RestartPolicy: dockercontainer.RestartPolicy{Name: "unless-stopped"}, } networkConfig := network.NetworkingConfig{}