Add a Docker Swarm Endpoint
Add a Docker Swarm Endpoint is very straighforward in Portainer CE 2.0.
Deploy the Agent.
Once logged into Portainer, go to Endpoints and select Agent as the Environment Type.
In the tabbed section below titled Information, select Docker Swarm and copy the command. Note: It is important run the command in the Docker Swarm host before to fill the environment details.
Use this same command each time you want to add a new Docker Swarm endpoint:
curl -L https://downloads.portainer.io/agent-stack.yml -o agent-stack.yml && docker stack deploy --compose-file=agent-stack.yml portainer-agent
Once running in the Docker Swam host, the terminal will reply with something similar to:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 484 100 484 0 0 249 0 0:00:01 0:00:01 --:--:-- 249 Creating network portainer-agent_portainer_agent Creating service portainer-agent_agent
To validate is the Agent is running, you can run the following command:
docker service ls
The result of that command should be something like this:
ID NAME MODE REPLICAS IMAGE PORTS tshb6ee2710s portainer-agent_agent global 1/1 portainer/agent:latest
Now, we're ready to move on to the next step.
Finishing the configuration
Once the Agent is running in the Docker Swarm host, you need to fill the environment details. The following options are available:
- Name: This is a descriptive name for your endpoint. This field is required.
- Endpoint URL: Define your IP or name to connect to the endpoint (Docker Swarm Host) and specify the port (9001) if this is needed. This field is requiered.
- Public IP: URL or IP address where exposed containers will be reachable. This field is optional and will default to the endpoint URL.
In the Metadata section, you can define a group and tags for this endpoint.
See the following screenshot for reference.
When everything is set, you can click Add Endpoint. If successful, you will see this pop up at the top right corner.