How do I remove Portainer?

This will guide you through removing Portainer from Docker Standalone, Docker Swarm and Kubernetes environments.

Docker Standalone

Removing Portainer

If you changed the default name of the Portainer container, please use that; the command below assumes you used the default name.

Stop the Portainer container

To remove the Portainer server, first, stop the running Portainer container by executing the following docker stop command: 

docker stop portainer

Delete the Portainer container

Once the Portainer container is stopped, you can delete it using the following rm command:

docker rm portainer

Removing Portainer data volume

If you changed the default name of the Portainer data volume, please use that; the command below assumes you used the default name.

Delete the Portainer data volume

Ensure Portainer has been removed before attempting to delete the volume using the following command. 

Note that this command will irreversibly delete your Portainer data volume.

docker volume rm portainer_data

Removing Portainer Agents

If you changed the default name of the Portainer Agent container, please use that; the command below assumes you used the default name.

Stop the Portainer Agent container

To remove the Portainer Agent, first, stop the running Portainer Agent container using the following docker stop command:

docker stop portainer_agent

For Edge Agents:

docker stop portainer_edge_agent

Delete the Portainer Agent container

Once the Portainer Agent container is stopped, you can delete it using the following rm command:

docker rm portainer_agent

For Edge Agents:

docker rm portainer_edge_agent

 

Docker Swarm

Removing the Docker Swarm stack

For Portainer deployments via Docker Swarm and deployed via the Portainer stack, which includes Portainer, Portainer Agent, and the agent network, can be deleted using the following command. 

This assumes you followed the official Portainer documentation when deploying the Portainer Stack. If you have Edge Agents, refer to "Removing The Edge Agent Service" first.

docker stack rm portainer

Removing the Edge Agent service

If you are running Portainer Edge Agents, the service for this needs to be removed before removing the Docker Swarm stack.

docker service rm portainer_edge_agent

Removing the Docker Swarm volume

The Portainer data volume can now be removed by running the following command. 

Please note that this command will permanently delete your Portainer data volume.

docker volume rm portainer_portainer_data

 

Kubernetes Deployment

Removing the Portainer namespace

Portainer deployments created via Kubernetes can be removed by deleting the Portainer namespace. This process is the same whether Portainer was deployed via Helm or YAML.

This will remove all resources under the Portainer namespace, including Edge Agents. 

By default, the Persistent Volume is not retained when the namespace is removed. If you set your Persistent Volume to retain, you will need to delete it manually.

Please be aware that deleting namespaces in Kubernetes can result in the permanent loss of all resources within that namespace. Proceed with caution and ensure backups are in place if needed.

kubectl delete namespace portainer