docker深入2-UI之portainer的使用简介
2017-08-23 17:09
555 查看
docker深入2-UI之 portainer 的使用简介
2017/9/26
2017/9/26
一、前言 预计该 UI 仅满足部分需求,还有坑要填,部分需求得自己去实现。 配置实例 1、配置防火墙 示例: iptables -A INPUT -s 192.168.200.0/24 -p tcp -m tcp --dport 2375 -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 2375 -j DROP 最好是通过安全组之类的来限制,不要暴露到外网,以免未授权访问。 2、调整docker访问,允许内网访问 API 接口 sed -i "/^ExecStart/c ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://$(ip a |grep global |grep eth0 |awk '{print $2}' |cut -d'/' -f1):2375" /usr/lib/systemd/system/docker.service systemctl daemon-reload; systemctl restart docker 3、启动 portainer 首先,引用以下一段话,来表达数据持久化时要考虑的细节: https://docs.docker.com/engine/admin/volumes/bind-mounts/#choosing-the--v-or-mount-flag Differences between -v and --mount behavior Because the -v and --volume flags have been a part of Docker for a long time, their behavior cannot be changed. This means that there is one behavior that is different between -v and --mount. If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v will create the endpoint for you. It is always created as a directory. If you use --mount to bind-mount a file or directory that does not yet exist on the Docker host, Docker does not automatically create it for you, but generates an error. (本次示例仅在swarm集群的其中一个节点创建该目录即可,这样一来,没有该目录的节点,启动服务时将报错,后续可考虑使用 NFS 之类的共享存储来存放数据。) # mkdir -p /data/portainer_dev 使用 swarm 集群的方式运行: # docker service create \ --name portainer_dev \ --detach=true \ --publish 9000:9000 \ --constraint 'node.role == manager' \ --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \ --mount type=bind,src=/data/portainer_dev,dst=/data \ portainer/portainer \ -H unix:///var/run/docker.sock 或直接运行一个容器: # docker run --restart=unless-stopped -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v /data/portainer_dev:/data --name portainer_dev portainer/portainer -H unix:///var/run/docker.sock 4、请求UI界面 http://node_ip:9000 设置管理员密码。 二、FAQ 1、在 UI 中 service restart 策略 默认值为 none 的疑惑。 UI创建的 service 在页面显示策略的值为 none 但实际测试发现: 默认策略是:any [root@test01 ~]# docker service inspect --format '{{ .Spec.TaskTemplate.RestartPolicy.Condition }}' t001 any 且测试集群一个 node 下线后,指定的 service 的副本是否会自动漂移到其他 node 时发现: 命令行得到的的结果,符合预期; UI 得到的结果,不符合预期;(任务还在已经下线的 node 中显示为 running 状态) 结论: UI 的显示错误。 2、在 UI 页面如何升级 portainer 这个 service 呢? 获取新版本的 digests 串: ]# docker images --digests |grep portainer 例如: 从 sha256:81e216c4b05ab16fbabb69e447fbe0ee408e29cc3aab0404e21e7507d3648df5 升级为: sha256:c56769dbee09a51af76d7df9fdc5d18411a4328cf1db512416b858a0f831d925 则新的 image 为: portainer/portainer:latest@sha256:c56769dbee09a51af76d7df9fdc5d18411a4328cf1db512416b858a0f831d925 更新该 service 后刷新下页面即可使用新版本。 3、如何限制 CPU 等资源 请升级到 1.14.1 以后的版本 Add the ability to manage CPU/MEM limits & reservations for Swarm services: #516 4、如何默认不显示所有的容器 请升级到 1.14.1 以后的版本 Persist the status of the show all containers filter: #1198 ZYXW、参考 1、doc https://portainer.readthedocs.io/en/latest/deployment.html 2、github https://github.com/portainer/portainer/releases[/code]
相关文章推荐
- docker深入2-UI之portainer的二次开发
- docker深入2-UI之portainer通过API来更新service的ACL
- FLASH MX UI Components 的使用方法简介
- 【Facebook的UI开发框架React入门之八】Image的使用简介(iOS平台)-goodmao
- docker深入2-存储驱动之使用devicemapper(direct-lvm)模式
- 在NGUI中高效优化UIScrollView之UIWrapContent的简介以及使用
- docker深入2-使用jenkins镜像
- Docker简介/安装/使用
- UIScrollView结合UIPageControl+NSTimer使用简介
- Docker for Windows使用简介
- Docker 图形化管理工具 Portainer 使用概要
- 深入了解前端路由的实现机制以及angularjs-route-ui的使用
- angular-ui-calendar使用简介
- Docker for Windows使用简介
- docker swarm集群搭建及使用Portainer、shipyard
- DockerUI安装、使用
- Web自动化框架LazyUI使用手册(1)--框架简介
- iOS-UICollectionView的使用简介
- Docker简介与使用(一)
- django debug toolbar使用简介,及docker中使用