docker swarm init



Portainer installation using 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 (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.
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 -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.
Deploy Portainer Server on a standalone WINDOWS Docker Host (running Windows Containers) – note must be Windows 1803 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

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 Swarm cluster with Portainer Server and the Portainer Agent

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.
