Portainer

Portainer-图形化Docker管理界面

Portainer可以图形化界面管理Docker服务,单机的情况下只需要部署一个Portainer容器即可,通过映射docker.sock文件和docker通信,如果是集群的情况下,可以在其它机器部署Portainer Agent容器来提供更全面的管理能力

需要的镜像

docker pull portainer/portainer-ce:2.0.0
docker pull portainer/agent:2.0.0

系统要求

Portainer is only officially supported running on Linux (CentOS 7 & 8, Ubuntu 16.04.6 LTS, 18.04.4 LTS, and 20.04 LTS) and Windows (Win 10 >1909 and Server 2019 >1909). Portainer is not tested on MacOS, or any other OS or OS family/version.

部署单机docker环境中

[root@192-168-31-100 ~]# docker volume create portainer_data
[root@192-168-31-100 ~]# docker run -d -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:2.0.0

访问9000端口即可访问,首次访问要设置一个密码

选择第一个,也就是单机docker环境

容器管理页面截图

部署到swarm集群中

最终的效果是,manager节点部署一个Portainer Server,所有节点以global模式部署Portainer Agent

$ curl -L https://downloads.portainer.io/portainer-agent-stack.yml -o portainer-agent-stack.yml
$ docker stack deploy --compose-file=portainer-agent-stack.yml portainer

上面两条命令是官方部署步骤,这种操作方式就是swarm使用docker-compose的YAML文件来启动服务,我把上面的文件下载下来,在镜像版本那块改成固定的
[root@192-168-31-100 ~]# cat  portainer-agent-stack.yml
version: '3.2'

services:
  agent:
    image: portainer/agent:2.0.0
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /var/lib/docker/volumes:/var/lib/docker/volumes
    networks:
      - agent_network
    deploy:
      mode: global
      placement:
        constraints: [node.platform.os == linux]

  portainer:
    image: portainer/portainer-ce:2.0.0
    command: -H tcp://tasks.agent:9001 --tlsskipverify
    ports:
      - "9000:9000"
      - "8000:8000"
    volumes:
      - portainer_data:/data
    networks:
      - agent_network
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]

networks:
  agent_network:
    driver: overlay
    attachable: true

volumes:
  portainer_data:

Note that this method will automatically deploy a single instance of the Portainer Server, and deploy the Portainer Agent as a global service on every node in your cluster.

参考

https://www.portainer.io/
https://www.portainer.io/documentation/