saltstack-formulas / docker-formula

Install and set up Docker
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
136 stars 330 forks source link

Optionally support removing container before trying to start it #238

Closed solarchad closed 4 years ago

solarchad commented 4 years ago

PR progress checklist (to be filled in by reviewers)


What type of PR is this?

Primary type

Secondary type

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

Describe the changes you're proposing

This should avoid this problem when trying to start the service (and the container was created but not running). For example:

/usr/bin/docker: Error response from daemon: Conflict. The container name "/ecs-agent" is already in use by container "22cb0febefdfe96ba2558dd33329fb428c7ed45a2145361d25e8faf331b18428". You have to remove (or rename) that container to be able to reuse that name.

I hit the problem with the AWS ecs-agent and in their ECS developer guide (on page 212), you can see that they have their systemd unit file using an ExecStartPre to remove the container before trying to start it.

This is useful if say the container gets created from a failed run. If you try to run it again, it will continue to fail because the container was created with the same name.

Pillar / config required to test the proposed changes

See the pillar.example.

Debug log showing how the proposed changes work

Documentation checklist

Testing checklist

Additional context

solarchad commented 4 years ago

Thanks @myii. I made these changes but I see that Travis is still unhappy. Is it failing for unrelated reasons now?

myii commented 4 years ago

@solarchad The commitlint is passing now but the yamllint is still failing on the same lines.

https://travis-ci.com/saltstack-formulas/docker-formula/jobs/278367547#L298-L301

$ yamllint -s .
./pillar.example
  18:28     warning  truthy value should be one of [false, true]  (truthy)
  44:28     warning  truthy value should be one of [false, true]  (truthy)

Perhaps you didn't add the changes to the latest commit you pushed?

solarchad commented 4 years ago

Whoops, sorry about that. I forgot to add the pillar.example before the last push. Just added it and pushed again. 🤞

saltstack-formulas-travis commented 4 years ago

:tada: This PR is included in version 0.43.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: