Stop a Docker Resource also removes container even though it is set to only stop it

(Eduard Sergeev) #1

Hi there,

We are trying to use Octopus to deploy Docker containers (on linux). As a part of deployment we are trying to use Stop a Docker Resource step to stop currently running container (from a previous deployment) but even though we configured the step only to stop container it also deletes it.
Here are the relevant parts of the deployment log:

Octopus Server version: 2019.6.8+Branch.tags-2019.6.8.Sha.2813706b187ebc8c2f63ed14cd888df3dc271563
Using Calamari.linux-x64 6.0.0
OperatingSystem: Linux ip-172-31-1-171.ap-southeast-2.compute.internal 4.14.138-114.102.amzn2.x86_64 #1 SMP Thu Aug 15 15:29:58 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Docker version 18.06.1-ce, build e68fc7a215d7133c34aa18e3b72b4a21fd0c6136
Using filter: --filter label=Octopus.Project.Id=Projects-81 --filter label=Octopus.Environment.Id=Environments-2
Stopping container: /suspicious_chaplygin
Removing container: /suspicious_chaplygin

The last line is unexpected and unwanted but we are not sure why it happens and how to force the step only to stop the container.

Also a question regarding retention policy in relation to Docker containers deployed over SSH: does it have any affect on them? I.e. will the containers/images be deleted when retention policy deletes the release?

(Matt Richardson) #3

Hi Eduard

Thanks for getting in touch! Sorry to see you’re having issues here - it seems that you’re definitely hitting a bug. Looking at the code, it seems to not pay any attention to the “stop” vs “stop and remove” options - it always hits the “stop and remove”.

Can you outline your use case a bit more here, so I can understand what you’re trying to do?

The script we’ve got:

  1. removes the network matching the filter
  2. stops the containers matching the filter
  3. removes the containers matching the filter

In the stop only scenario, would you expect the network to be removed? I assume no, but will be good to understand your expectations here.

I’ve logged an issue which you can follow to get notified when this is fixed.

For now, I would suggest using a script step that runs docker stop --filter label=Octopus.Project.Id=Projects-81 --filter label=Octopus.Environment.Id=#{Octopus.Environment.Id} - that should have the desired behavior.

Looking forward to your feedback on making this better.