简体   繁体   中英

docker-compose run existing container

I'm running an application under development with docker-compose.

I have a "web" service running a python Flask web application. This service depends on other ones (database, cache, ...).

I need to run the "web" main service interactively in order to get access to a debugger (ipdb). I found out that the way to do this would be

docker-compose run --name my-app.web --service-ports web

When I exit this container and try to run it again with the same command I got this error:

ERROR: Cannot create container for service web: Conflict. The container name "/my-app.web" is already in use by container "4fed84779bb02952dedb8493a65bd83b1a6664f066183233e8c8b4dc62291643". You have to remove (or rename) that container to be able to reuse that name.

How can I start again this container without creating a new one ?

Or is it the correct way to create new containers each time I need to start this application ?

Or did I miss something to be able to start one of the service interactively ?

As you're setting a custom name, docker-compose run doesn't remove the container once the execution is completed. To enable this behavior use the option --rm :

docker-compose run --rm --name my-app.web --service-ports web

You can also remove the container manually to be able to run it again:

docker rm my-app.web

This is not necessary if you don't set a custom name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM