Managing containers on the command line can get a little tedious over time, and we need a visual interface to help simplify our work.
1. Install Portainer-Agent
⚠️ Both machines need to be operated
It is unsafe to directly open docker’s Access API (port 2375), especially in production environments. Therefore, we use agent to manage Docker instead of directly connecting docker port 2375. Next, we installed Portainer-Agent on both machines.
Run the following command on test-Node-1:
docker run -d \
--network app_network \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /data/docker/volumes:/var/lib/docker/volumes \
--name portainer_agent_1 \
portainer/agent
Copy the code
Run it on the test-Node-2 machine
docker run -d \
--network app_network \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /data/docker/volumes:/var/lib/docker/volumes \
--name portainer_agent_2 \
portainer/agent
Copy the code
After the installation, let’s set it aside.
2, install portainer-CE
Portainer-ce is a visual management tool of Docker. Portainer-ce of the 2. X series has been renamed as Portainer-CE. It is worth noting that Portainer-CE no longer supports direct connection with Port 2375 of Docker, and it seems that this security issue has been paid more attention.
Run the following command on test-node-1:
docker run -d \
-p 8000:8000 \
-p 9000:9000 \
--name=portainer \
--network=app_network \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /data/portainer:/data \
portainer/portainer-ce
Copy the code
3, portainer-CE configuration
After the installation, visit http://172.16.113.9:9000 in the browser. Since it is the first time to open it, we need to set the account and password. When we’re done, we’ll go to this step:
Select the Agent option, fill in Portainer_Agent_1, Portainer_Agent_1 :9001, then click the Connent button and we can enter normally. Some of you might be wondering why you didn’t put in the IP address. Because portainer-CE and Portainer-Agent are installed in the same network segment, they can be accessed using container names.
At this point, there is only one node, and we need to add another node to it:
Select agent again, and then fill in the parameters of the second agent:
Click on the bottom after filling inAdd endpoint
Button.
Now back to the Home page, we can find that both nodes are present and can be clicked to see more information. The following 2 pictures:
4, summary
This section mainly uses Portainer-CE to manage docker, and communicates with Portainer-CE through Portainer agent.