portainer使用二进制文件安装

一.安装portainer

1.1 查看portainer版本信息

版本信息

可在此查看到每个版本的详细信息

1.2 下载文件

下载并将二进制文件

[root@localhost opt]# wget https://github.com/portainer/portainer/releases/download/1.20.1/portainer-1.20.1-linux-amd64.tar.gz
--2019-03-05 13:21:00--  https://github.com/portainer/portainer/releases/download/1.20.1/portainer-1.20.1-linux-amd64.tar.gz
正在解析主机 github.com (github.com)... 13.229.188.59, 52.74.223.119, 13.250.177.223
正在连接 github.com (github.com)|13.229.188.59|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://github-production-release-asset-2e65be.s3.amazonaws.com/59239347/7e700400-255c-11e9-9e54-5044865ea28f?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190305%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190305T052100Z&X-Amz-Expires=300&X-Amz-Signature=d728457eff5f21815f5ca5c64d3bcace5f8b850ecb66d80785f01de9ce4bf383&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dportainer-1.20.1-linux-amd64.tar.gz&response-content-type=application%2Foctet-stream [跟随至新的 URL]
--2019-03-05 13:21:01--  https://github-production-release-asset-2e65be.s3.amazonaws.com/59239347/7e700400-255c-11e9-9e54-5044865ea28f?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190305%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190305T052100Z&X-Amz-Expires=300&X-Amz-Signature=d728457eff5f21815f5ca5c64d3bcace5f8b850ecb66d80785f01de9ce4bf383&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dportainer-1.20.1-linux-amd64.tar.gz&response-content-type=application%2Foctet-stream
正在解析主机 github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.132.163
正在连接 github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.132.163|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:21945155 (21M) [application/octet-stream]
正在保存至: “portainer-1.20.1-linux-amd64.tar.gz”

100%[==========================================================================================>] 21,945,155   570KB/s 用时 2m 1s  

2019-03-05 13:23:04 (177 KB/s) - 已保存 “portainer-1.20.1-linux-amd64.tar.gz” [21945155/21945155])

1.3 解压文件

解压缩到磁盘上的某个位置

[root@localhost opt]# tar zxvf portainer-1.20.1-linux-amd64.tar.gz 

[root@localhost opt]# ls
portainer

1.4 新建portainer数据存储目录

Portainer默认会尝试将其数据写入/ data文件夹,但我们可以更改它的数据存储目录

[root@localhost opt]# mkdir /opt/portainer-data

1.5 启动portainer

[root@localhost opt]# cd portainer
[root@localhost portainer]# ls
docker  portainer  public  templates.json

启动portainer
[root@localhost portainer]#  ./portainer --data /opt/portainer-data --template-file "${PWD}/templates.json" &
[1] 7824
[root@localhost portainer]# 2019/03/05 13:49:51 Starting Portainer 1.20.1 on :9000

[root@localhost portainer]# cd /opt/portainer-data/
[root@localhost portainer-data]# ls
bin  compose  config.json  portainer.db  portainer.key  portainer.pub  tls

注意:

如果portainer的默认端口9000在你的服务器已经被占用或者不方便使用,也使用该-p标志在另一个端口上为Portainer提供服务:

如下例:

[root@localhost portainer]#  ./portainer --data /opt/portainer-data  -p :8080 --template-file "${PWD}/templates.json" &
[1] 7949

[root@localhost portainer]# 2019/03/05 13:57:37 Templates already registered inside the database. Skipping template import.
2019/03/05 13:57:37 Starting Portainer 1.20.1 on :8080

[root@localhost portainer]# 
[root@localhost portainer]# netstat -lnptu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp6       0      0 :::8080                 :::*                    LISTEN      7949/./portainer

注意:

可以在启动容器的时候直接在命令内设置参数,来修改portainer的默认行为,可使用的参数使用./portainer --help命令查看:

[root@localhost portainer]# ./portainer --help
usage: portainer [<flags>]

Flags:
      --help                     Show context-sensitive help (also try --help-long and --help-man).
      --version                  Show application version.
  -p, --bind=":9000"             Address and port to serve Portainer
  -a, --assets="./"              Path to the assets
  -d, --data="/data"             Path to the folder where the data is stored
  -H, --host=HOST                Endpoint URL
      --external-endpoints=EXTERNAL-ENDPOINTS  
                                 Path to a file defining available endpoints
      --no-auth                  Disable authentication
      --no-analytics             Disable Analytics in app
      --tlsverify                TLS support
      --tlsskipverify            Disable TLS server verification
      --tlscacert="/certs/ca.pem"  
                                 Path to the CA
      --tlscert="/certs/cert.pem"  
                                 Path to the TLS certificate file
      --tlskey="/certs/key.pem"  Path to the TLS key
      --ssl                      Secure Portainer instance using SSL
      --sslcert="/certs/portainer.crt"  
                                 Path to the SSL certificate used to secure the Portainer instance
      --sslkey="/certs/portainer.key"  
                                 Path to the SSL key used to secure the Portainer instance
      --sync-interval="60s"      Duration between each synchronization via the external endpoints source
      --snapshot                 Start a background job to create endpoint snapshots
      --snapshot-interval="5m"   Duration between each endpoint snapshot job
      --admin-password=ADMIN-PASSWORD  
                                 Hashed admin password
      --admin-password-file=ADMIN-PASSWORD-FILE  
                                 Path to the file containing the password for the admin user
  -l, --hide-label=HIDE-LABEL ...  
                                 Hide containers with a specific label in the UI
      --logo=LOGO                URL for the logo displayed in the UI
  -t, --templates=TEMPLATES      URL to the templates definitions.
      --template-file="/templates.json"  
                                 Path to the templates (app) definitions on the filesystem

二、portminer模板

portainer中可以自定义一些模板,然后在portainer中创建容器的时候使用这些模块快速的创建,模板是json格式的,包含一些必选项和可选项。

可看见在启动portminer时,添加的一个参数:–template-file “${PWD}/templates.json”
portminer模板便存储在templates.json文件中

摘取一段templates.json文件中的内容为大家解释一下

2.1 portminer模板样例
[root@localhost portainer]# ls
docker  portainer  public  templates.json
[root@localhost portainer]# cat templates.json 
[
  {
    "type": 1,
    "title": "Registry",
    "description": "Docker image registry",
    "categories": ["docker"],
    "platform": "linux",
    "logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/registry.png",
    "image": "registry:latest",
    "ports": [
      "5000/tcp"
    ],
    "volumes": [{ "container": "/var/lib/registry"}]
  },
  {
    "type": 1,
    "title": "Nginx",
    "description": "High performance web server",
    "categories": ["webserver"],
    "platform": "linux",
    "logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/nginx.png",
    "image": "nginx:latest",
    "ports": [
      "80/tcp",
      "443/tcp"
    ],
    "volumes": [{"container": "/etc/nginx"}, {"container": "/usr/share/nginx/html"}]
  },

2.2 portminer模板解释

type 必选项,1表示container,2表示swarm stack,3表示compose stack

title 必选项

description 必选项,该镜像描述

image 必选项,该应用使用的docker镜像

administrator_only 可选项,是否只有管理员可用模板

name 可选项,该模板在管理界面中显示的名称

logo 可选项,自定义的logo

registry 可选项,docker镜像的仓库,默认是Dockerhub

command 可选项,容器里面运行的命令,如果没有指定,则默认运行dockerfile的command

network 可选项,模板使用的网络

volumes 可选项,模板使用的volume

ports 可选项,模板exposed的端口

labels 可选项,模板上定义的labels

privileged 可选项,容器是否能在超级权限启动

interactive 可选项,容器启动时是否是交互模式,即添加-i -t

restart_policy 可选项,容器的重启策略

hostname 可选项,容器的主机名

note 可选项,关于模板的信息

platform 可选项,支持的平台,一般是linux或者windows

categories 可选项,模板的类别,可以在UI上通过category来过滤


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杰哥的技术杂货铺

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值