Install Portainer Agent with Docker on WSL / Docker Desktop
Portainer uses the Portainer Agent container to communicate with the Portainer Server instance and provide access to the node's resources. This document will outline how to install the Portainer Agent on your node and how to connect to it from your Portainer Server instance. If you do not have a working Portainer Server instance yet, please refer to the Portainer Server installation guide first.
You will need:
- The latest version of Docker Desktop installed and working.
- Administrator access on the machine that will host the Portainer Agent.
- Windows Subsystem for Linux (WSL) installed and a Linux distribution selected. For a new installation we recommend WSL2.
The installation instructions also make the following assumptions about your environment:
- You are accessing Docker via Unix sockets. Alternatively, you can also connect via TCP.
- SELinux is disabled within the Linux distribution used by WSL. If you require SELinux, you will need to pass the
--privilegedflag to Docker when deploying Portainer.
- Docker is running as root. Portainer with rootless Docker has some limitations, and requires additional configuration.
- You have not set a custom
AGENT_SECRETon your Portainer Server instance. If you have, you will need to provide that secret to your agent when deploying with:
Run the following command to deploy the Portainer Agent:
docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes portainer/agent:latest
Once the agent has been installed you are ready to add the environment to your Portainer Server installation.