How to remove single container created with Docker-Compose

Asked

Viewed 277 times

0

I have a file Docker-Compose.yml with various image settings. To upload all I can use the docker-compose up -d and stop docker-compose down, if I only want to upload a configured service docker-compose up -d nomeDoServico.

Now I need to stop only one service configured, and using the docker-compose down nomeDoServico does not work. I did not want to stop the container, removing it and removing the Networks manually.

I need to remove a container, and your networks and start it again, how to do it?

  • Tried to use command stop and rm? In your case: docker-compose stop nomeDoServico and then docker-compose rm nomeDoServico. The network can only be removed with down even, but maybe you can do this after using the stop (I suppose).

  • the docker-compose rm -s -f nomeDoServico worked out, thanks @Dherik

1 answer

2


You can use the command stop followed by rm for this.

First, stop the service with the stop:

docker-compose stop nomeDoServico

Then remove the stopped service with the rm:

docker-compose rm nomeDoServico

As pointed out by the author of the question himself, you can also use the options -s and -f to stop and force the removal in a single command:

docker-compose -s -f rm nomeDoServico

Browser other questions tagged

You are not signed in. Login or sign up in order to post.