docker可视化工具Portainer

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
 

猜你喜欢

转载自blog.csdn.net/csj50/article/details/120200799