Skip to content

Commit

Permalink
Purge exited container
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienbeau committed Oct 16, 2024
1 parent a29bd92 commit 0c60eeb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docky/cmd/run_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ class DockyRun(DockyExec):
"""Start services and enter in your dev container"""

def _check_running(self):
if docker.compose.ps(services=[self.service], all=True):
raise_error("This container is already running, kill it or "
"use open to go inside")
for service in docker.compose.ps(services=[self.service], all=True):
if service.state.status == "exited":
# In case that you have used "docker compose run" without the
# option "--rm" you can have exited container
# we purge them here as they are useless
service.remove()
else:
raise_error("This container is already running, kill it or "
"use open to go inside")

def _main(self, *optionnal_command_line):
super()._main(*optionnal_command_line)
Expand Down

0 comments on commit 0c60eeb

Please sign in to comment.