[5 minutes to play lighthouse] lightweight application server can easily play docker

Tears of wind 2022-06-24 07:33:11 阅读数:268


1. Application scenarios

Before Lighthouse 5 In the minute series , Introduced the use of Docker Build application services on lightweight application servers , such as build bitwarden Personal password manager , build calibre-web Personal online library , Create immersive Markdown Writing environment . These tutorials use commands to operate Docker, And in multiple lightweight application servers Docker The container needs to log in to multiple servers for management , Not very convenient . This article introduces , Use Portainer Manage multiple lightweight application servers in a visual way Docker Containers .

2. Portainer brief introduction

Portainer Is a free and open source container graphical management tool . It can communicate with... At data center and edge nodes Kubernetes,Docker,Docker Swarm,Azure ACI Work together .

Portainer Eliminates complex choreography , This allows developers to quickly 、 Easy and accurate deployment of applications . In addition to managing applications , It can also be used to observe the behavior of containers , It manages the underlying platform and provides users with the ability of security inspection and permission control , Make container deployment more secure .

The picture below is Portainer Provided by the official website Portainer Functional orientation .

3. Portainer And lightweight application server

The lightweight application server comes with Docker Mirror image , Individual developers may work in multiple lightweight application servers , Run multiple Docker Containers , Use Portainer It can be used for Docker Containers are managed centrally and graphically .Portainer There is a very friendly control page , This allows users to be unfamiliar with Docker In the case of an order , Yes Docker Container management , It's very convenient to use . As shown in the figure below .

4. Portainer install

Next , Let's talk about how to use Portainer Server Manage... In multiple lightweight application servers Docker Containers . The following figure is the overall architecture diagram .

4.1. install Portainer Server

We need one with Docker Mirrored lightweight application servers ( For purchasing methods, please refer to Lighthouse5 Minute tutorial ), Use Docker To install Portainer Server. Use the one click login function in Tencent cloud lightweight application server console , logon server , Use the following command to install Portainer Server.

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

4.2. The firewall is unblocked Portainer port

On the firewall page of the lightweight application server instance , Let go Portainer Port used .

4.3. Sign in Portainer Server

Access in a browser http://ip:9000, First set the password of the login account , Then you can log in Portainer The management page of .

4.4. Manage native Docker Containers

Now we want to manage the local Docker Containers , Choose here Docker, And then click Connect.

This is the local Docker It is incorporated into Portainer Server In the management of , We can see that there are already three containers running locally .

4.5. Manage remote Docker Containers

4.5.1. Release the far end Docker Container of API control

Use Portainer Manage remote Docker Containers , Then we should release the remote server Docker Of API control .SSH Log in to the remote lightweight application server and perform the following operations .

sudo root
vim /usr/lib/systemd/system/docker.service
# stay ExectStart Add... To the parameter -H tcp:// -H unix:///var/run/docker.sock
ExecStart=/usr/bin/dockerd -H tcp:// -H unix:///var/run/docker.sock -H fd:// --containerd=/run/containerd/containerd.sock

preservation systemd After the configuration file , restart Docker.

systemctl daemon-reload && systemctl restart docker

4.5.2. The firewall is unblocked Docker API port

At the firewall console of the remote lightweight application server , Let go Docker API port 2375.

4.5.3. Add remote Docker Of Endpoint

Open the remote server Docker API After the port , We are Portainer Navigation bar to find Endpoints, Add a new one Endpoint.

Endpoint Url, Enter the name of the remote lightweight application server IP Address , port 2375. If the remote server is connected to Portainer Server Both are lightweight application servers in the same region , We input the intranet IP. If it is a lightweight application server in different regions , We need to input the Internet IP.

In this way, the remote lightweight application server Docker Containers , It can also be in Portainer Managed in .

5. Portainer Use

Now let's introduce the use of Portainer Yes Docker Conduct management .

5.1. Use AppTemplates install Nginx

5.1.1. install Nginx

Portainer Bring their own App Templates, It contains some commonly used docker Containers , choice Nginx install .

Name For the name of the container , Input nginx, Click on Deploy the container.

5.1.2. see Container list

After installation , stay Container list in , notice nginx It's already started .

5.1.3. visit Nginx

Here we visit http://ip:32776

5.2. Use Stack install chevereto

stay Portainer Stack Can be used in Docker-compose Install application . Here we use 《【5 Minutes to play Lighthouse】 Create immersive Markdown Writing environment 》 In this article docker-compose file , stay Portainer Install in chevereto Picture bed .

5.2.1. establish Stack

stay Stacks page , Click on CreateStack, And then docker-compose The contents of the file are copied and pasted Web editor in , Click on Deploy. As shown in the figure below .

5.2.2. see Stack details

wait for Stack After successful deployment , Can be in Stack details View in docker-compose All containers started .

5.2.3. visit chevereto

Access in a browser http://ip:80 You can see that chevereto The page .

6. summary

Use Portainer Provide a graphical interface , We can easily manage multiple lightweight servers Docker Containers , No more command line input Docker command , The deployment of the container can be completed 、 stop it 、 Delete and open .Portainer Further reduced Docker Use threshold of , So that we can devote more energy to service , Concentrate on finishing the work .

This article is limited to space , Only Portainer Installation 、Endpoint management 、 Single container deployment and Docker Compose Contents of the deployment of multiple containers . actually Portainer Container mirroring is also possible 、 The Internet 、 Data volume 、Docker Image warehouse management and other work , These contents can be found later Lighthouse 5 In the minute series of tutorials .

7. Reference material

1. Tencent cloud lightweight application server :https://cloud.tencent.com/product/lighthouse

2. Portainer:https://www.portainer.io/

3. 【5 Minutes to play Lighthouse】 Create immersive Markdown Writing environment :https://cloud.tencent.com/developer/article/1831170

copyright:author[Tears of wind],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/175/20210630195005974Z.html