Portainer is comprised of two elements, the Portainer Server, and the Portainer Agent. Both elements run as lightweight Docker containers on a Docker engine or within a Swarm cluster. Due to the nature of Docker, there are many possible deployment scenarios, however, we have detailed the most common below. Please use the scenario that matches your configuration (or if your configuration is not listed, see portainer.readthedocs.io for additional options).
Note that the recommended deployment mode when using Swarm is using the Portainer Agent.
Use the following Docker commands to deploy the Portainer Server; note the agent is not needed on standalone hosts, however it does provide additional functionality if used (see portainer and agent scenario below):
$ docker volume create portainer_data
$ docker run -d -p 8000:8000 -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
You'll just need to access the port 9000 of the Docker engine where portainer is running using your browser.
Note: the -v /var/run/docker.sock:/var/run/docker.sock option can be used in Linux environments only.
$ docker volume create portainer_data
$ docker run -d -p 8000:8000 -p 9000:9000 --name portainer --restart always -v \\.\pipe\docker_engine:\\.\pipe\docker_engine -v portainer_data:C:\data portainer/portainer
You'll just need to access the port 9000 of the Docker engine where portainer is running using your browser.
Note: the -v \\.\pipe\docker_engine:\\.\pipe\docker_engine option can be used in Windows 1803+ Container environments only.
Deploying Portainer and the Portainer Agent to manage a Swarm cluster is easy ! You can directly deploy Portainer as a service in your Docker cluster. Note that this method will automatically deploy a single instance of the Portainer Server, and deploy the Portainer Agent as a global service on every node in your cluster.
$ curl -L https://downloads.portainer.io/portainer-agent-stack.yml -o portainer-agent-stack.yml
$ docker stack deploy --compose-file=portainer-agent-stack.yml portainer
You'll just need to access the port 9000 of the Docker engine where portainer is running using your browser.
Deploying Portainer and the Portainer Agent to manage a Windows 2016 (1803) or Windows 2019 (10903) Swarm cluster is easy ! You can directly deploy Portainer as a service in your Docker cluster. Note that this method will automatically deploy a single instance of the Portainer Server, and deploy the Portainer Agent as a global service on every node in your cluster.
$ curl https://downloads.portainer.io/portainer_windows_stack.yml -o portainer_windows_stack.yml
$ docker stack deploy --compose-file=portainer_windows_stack.yml portainer
You'll just need to access the port 9000 of the Docker engine where portainer is running using your browser.
Note, ensure that the required network ports are exposed on the Docker Hosts in your cluster PRIOR to deploying the stack (and reboot your host after adding the rules).
netsh advfirewall firewall add rule name="cluster_management" dir=in action=allow protocol=TCP localport=2377
netsh advfirewall firewall add rule name="node_communication_tcp" dir=in action=allow protocol=TCP localport=7946
netsh advfirewall firewall add rule name="node_communication_udp" dir=in action=allow protocol=UDP localport=7946
netsh advfirewall firewall add rule name="overlay_network" dir=in action=allow protocol=UDP localport=4789
netsh advfirewall firewall add rule name="swarm_dns_tcp" dir=in action=allow protocol=TCP localport=53
netsh advfirewall firewall add rule name="swarm_dns_udp" dir=in action=allow protocol=UDP localport=53
Deploy Portainer Agent on a remote LINUX Swarm Cluster as a Swarm Service, run this command on a manger node in the remote cluster.
$ docker service create --name portainer_agent --network portainer_agent_network --publish mode=host,target=9001,published=9001 -e AGENT_CLUSTER_ADDR=tasks.portainer_agent --mode global --mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock --mount type=bind,src=//var/lib/docker/volumes,dst=/var/lib/docker/volumes –-mount type=bind,src=/,dst=/host portainer/agent
Deploy Portainer Agent on a standalone Windows Server 2016 Docker Host
$ docker run -d -p 9001:9001 --name portainer_agent --restart=always -v \\.\pipe\docker_engine:\\.\pipe\docker_engine portainer/agent
Deploy Portainer Agent on SINGLE Windows Server 2016 Docker Host running as a Swarm Node (for multi-node deployments, please see advanced configurations)
$ docker run -d -p 9001:9001 --name portainer_agent --restart=always -v \\.\pipe\docker_engine:\\.\pipe\docker_engine -e AGENT_CLUSTER_ADDR=tasks.agent portainer/agent
Note: the three options above only deploy the agent, you must connect to the agent from an existing Portainer Server instance.
To see how to use our Edge compute agent, see the user guides here: https://downloads.portainer.io/edge_agent_guide.pdf
For a list of our most frequently asked questions, please see here: https://portainer.readthedocs.io/en/stable/faq.html
Have a look at our installation documentation for more deployment scenarios such as Portainer with data persistence, TLS authentication enabled engine, non-Docker setup or reverse proxy integrations.https://portainer.readthedocs.io/en/stable/deployment.html