1、安裝按照官方網站教程
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
2、Portainer分成Community Edition和Business Edition,一個是社群版另一個是商業版
3、8000端口是TCP隧道服務的端口,9000端口是web UI的通路端口
4、Portainer Server和Portainer Agent Only
Portainer Server是工具的主體,Portainer Agent Only是在docker叢集中用于服務端連接配接到節點執行Docker API請求
5、安裝設定
通路http://ip-server:9000
1)設定使用者名和密碼

2)選擇安裝模式
這裡選擇第一個管理local的docker環境
6、下載下傳鏡像
填入image:tag,點選Pull the image
相當于:docker pull nginx:1.21
7、建立容器
1)端口映射
在Manual network port publishing下面設定,相當于:-p 80:80
2)目錄挂載
注意選擇Bind,不是添加卷
相當于:-v /appserver/nginx/default.conf:/etc/nginx/conf.d/default.conf -v /appserver/nginx/logs/:/var/log/nginx/ -v /appserver/nginx/code/:/var/www/html
3)建立
前提是需要先建立挂載的目錄和檔案:
建立以下目錄
/appserver/nginx/
/appserver/nginx/logs/
/appserver/nginx/code/
添加default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /var/www/html;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
添加index.html
<html>
<body>hello world</body>
</html>
8、通路http://ip-server:80
9、Portainer添加管理伺服器
1)被管理機器安裝agent
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
2)管理端設定
輸入Name(伺服器名稱),Endpoint URL(IP:PORT),PUBLIC IP(IP)
感覺沒有安全認證的東西,不能放在外網上
參考資料:
https://documentation.portainer.io/v2.0/deploy/ceinstalldocker/
https://blog.csdn.net/iteye_10432/article/details/99161578
https://www.cnblogs.com/hellxz/p/install_portainer.html