Installing Portainer

Register to Stay in Contact

How simple is it to deploy Portainer?

Portainer running within Kubernetes

To deploy Portainer within a Kubernetes cluster, you can either use our HELM chart, or our provided manifests.

Note that Portainer CE 2.0 supports Kubernetes version 1.16, 1.17 and 1.18 only.

Pre-Req Note:

Portainer requires data persistence, and as a result needs at least one storage-class available to use. Portainer will attempt to use the "default" storage class during deployment. If you do NOT have a storage class tagged as "default" the deployment will likely fail.

You can check if you have a default storage class by running:

> kubectl get sc

and looking for a storage class with (default) after its name:

If you want to make a storage class the default, you can type the command:

> kubectl patch storageclass <storage-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

and replace <storage-class-name> with the name of your storage class (eg: kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

Alternatively, if you are using HELM you can use: --set persistence.storageClass=<storage-class-name>

If using HELM...

First, add the Portainer helm repo

> helm repo add portainer https://portainer.github.io/k8s/

> helm repo update

Then create the Portainer namespace in your cluster

> kubectl create namespace portainer

Then deploy Portainer..

For NodePort

> helm install -n portainer portainer portainer/portainer

or if you need to set persistence manually:

        > helm install -n portainer portainer portainer/portainer --set persistence.storageClass=<storage-class-name>

Portainer will be on Port 30777 when using NodePort

For Load Balancer

> helm install -n portainer portainer portainer/portainer --set service.type=LoadBalancer

or if you need to set persistence manually:

        > helm install -n portainer portainer portainer/portainer --set service.type=LoadBalancer --set persistence.storageClass=<storage-class-name>

Portainer will be on Port 9000 when using Load Balancer

For Ingress

> helm install -n portainer portainer portainer/portainer --set service.type=ClusterIP

or if you need to set persistence manually:

        > helm install -n portainer portainer portainer/portainer --set service.type=ClusterIP --set persistence.storageClass=<storage-class-name>

Or, if using Manifests...

Please ensure you have checked your default storage persistence before continuing...

First, create the Portainer namespace in your cluster

> kubectl create namespace portainer

Then deploy Portainer using NodePort from our Manifests

> kubectl apply -n portainer -f https://raw.githubusercontent.com/portainer/k8s/master/deploy/manifests/portainer/portainer.yaml

Portainer will be on Port 30777 when using NodePort

Or Deploy Portainer using Load Balancer from our Manifests

> kubectl apply -n portainer -f https://raw.githubusercontent.com/portainer/k8s/master/deploy/manifests/portainer/portainer-lb.yaml

Portainer will be on Port 9000 when using Load Balancer

 

Portainer running within Docker

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.

Note that the recommended deployment mode when using Swarm is using the Portainer Agent.

Portainer is only officially supported running on Linux (CentOS 7 & 8, Ubuntu 16.04.6 LTS, 18.04.4 LTS, and 20.04 LTS) and Windows (Win 10 >1909 and Server 2019 >1909). Portainer is not tested on MacOS, or any other OS or OS family/version.

Deploy Portainer Server on a standalone LINUX Docker host/single node swarm cluster (or Windows 10 Docker Host running in “Linux containers” mode).

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 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

You'll just need to access the port 9000 of the Docker engine where portainer is running using your browser.

Note: Port 9000 is the general port used by Portainer for the UI access. Port 8000 is used exclusively by the EDGE agent for the reverse tunnel function. If you do not plan to use the edge agent, you do not need to expose port 8000

Note: the -v /var/run/docker.sock:/var/run/docker.sock option can be used in Linux environments only.

Deploy Portainer Server on a standalone WINDOWS Docker Host (running Windows Containers) – note must be Windows 1909 or newer.

$ 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-ce

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.

Manage a LINUX Swarm cluster with Portainer Server and the Portainer Agent

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.

Manage a WINDOWS Server Swarm cluster with Portainer Server and the Portainer Agent

Deploying Portainer and the Portainer Agent to manage a Windows 2019 (1909) 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

PORTAINER AGENT DEPLOYMENTS ONLY

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 remote LINUX standalone Docker Host (no swarm), run this command

$ 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

Deploy Portainer Agent on a remote Windows Server 2019 Swarm Cluster, run this command

$ curl -L https://downloads.portainer.io/win-agent.yml -o win-agent.yml
$ docker stack deploy --compose-file=win-agent.yml portainer-agent

Deploy Portainer Agent on a standalone Windows 10 Docker Host (Windows Containers) or Windows Server 2019 Docker Host

$ docker run -d -p 9001:9001 --name portainer_agent --restart=always -v \\.\pipe\docker_engine:\\.\pipe\docker_engine portainer/agent

Note: the options above only deploy the agent, you must connect to the agent from an existing Portainer Server instance.

And more deployment scenarios

To see advanced deployment tips and techniques, see our documentation.