Remove container from Docker - Portainer

 

Remove container from Docker

You already know how to install PORTAINER in docker, otherwise, you are not supposed to search for removing it.

Here I am putting some easy commands that might help you to remove easily the portainer or any other container as well from your docker.


1. First, find all Docker containers list using the command:

docker container ls -a

2. stop the specific container, enter the following command:

docker container stop [container_id]

To stop all containers, enter: (ignore if you are you doing this for all)

docker container stop $(docker container ls –aq)

3. To remove the stopped container, use the command:

docker container rm [container_id]

To remove all stopped containers: (ignore if you are you doing this for all)

docker container rm $(docker container ls –aq)


Here I am mentioning that I did for removing my portainer from my docker.

-----------------------------------------------------------------------------------------------

Last login: Sat Nov 21 10:40:06 2020 from 192.168.0.175

mi@misrvr:~$ sudo docker container ls -a

[sudo] password for mi:

CONTAINER ID        IMAGE                    COMMAND             CREATED             STATUS              PORTS                                            NAMES

27d97e7b21d0        portainer/portainer-ce   "/portainer"        58 minutes ago      Up 3 minutes        0.0.0.0:8000->8000/tcp, 0.0.0.0:9000->9000/tcp   portainer

mi@misrvr:~$ docker container stop 27d97e7b21d0

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/27d97e7b21d0/stop: dial unix /var/run/docker.sock: connect: permission denied

mi@misrvr:~$ sudo docker container stop 27d97e7b21d0

27d97e7b21d0

mi@misrvr:~$ sudo docker container rm 27d97e7b21d0

27d97e7b21d0

mi@misrvr:~$ sudo docker container ls -a

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

mi@misrvr:~$

------------------------------------------------------------------------------------------------------



0 Comments