快速入门
最后更新于:2022-04-01 00:52:18
这篇文档描述如何快速启动和运行Shipyard。 Shipyard主要有两个组件:RethinkDB和接口。
## RethinkDB
启动一个RethinkDB实例:
~~~
docker run -it -d --name shipyard-rethinkdb-data --entrypoint /bin/bash shipyard/rethinkdb -l
~~~
启动一个数据挂载的RethinkDB容器实例:
~~~
docker run -it -P -d --name shipyard-rethinkdb --volumes-from shipyard-rethinkdb-data shipyard/rethinkdb
~~~
## 接口
启动Shipyard容器:
~~~
docker run -it -p 8080:8080 -d --name shipyard \
--link shipyard-rethinkdb:rethinkdb shipyard/shipyard
~~~
Shipyard将会创建一个用户名为`admin`密码为`shipyard`的默认账户。接下来你可以打开浏览器访问`http://:8080`并登陆查看。
## 引擎
接下来你可以使用web UI或者控制台接口来添加引擎。
## 设置
注意:基本本地socket(译者注:即unix:/var/run/docker.socket)是有限制的,并且不推荐使用。例如,端口暴露在web UI中不起作用,因为它并不知道引擎的IP。并且拓展镜像也不能基于引擎的IP。推荐的配置是使用TCP。如果你想使用socket设置来调试,请在IRC中访问我们。
为了配置一台主机,你需要使用TCP将Docker经常暴露出来。在Dcoker中配置TCP,你可以查看[Docker文档](https://docs.docker.com/articles/basics/)。你可以使用`http://:`作为`addr`在命令控制接口或者web UI增加一个引擎。
要了解更多信息请查看[引擎](http://dockerpool.com/engines.html)
接口
最后更新于:2022-04-01 00:52:16
hipyard的核心接口。这个接口可以管理集群中的所有操作。
## 账户
* [账户列表](http://dockerpool.com/static/books/shipyard_doc/api.html#get-accounts)
* [创建账户](http://dockerpool.com/static/books/shipyard_doc/api.html#post-accounts)
* [删除账户](http://dockerpool.com/static/books/shipyard_doc/api.html#delete-account)
## 角色
* [角色列表](http://dockerpool.com/static/books/shipyard_doc/api.html#get-roles)
* [角色详情](http://dockerpool.com/static/books/shipyard_doc/api.html#get-roles)
* [创建角色](http://dockerpool.com/static/books/shipyard_doc/api.html#post-roles)
* [删除角色](http://dockerpool.com/static/books/shipyard_doc/api.html#delete-role)
## 容器
* [容器列表](http://dockerpool.com/static/books/shipyard_doc/api.html#get-containers)
* [发布容器](http://dockerpool.com/static/books/shipyard_doc/api.html#post-containers)
* [容器详情](http://dockerpool.com/static/books/shipyard_doc/api.html#get-container)
* [删除容器](http://dockerpool.com/static/books/shipyard_doc/api.html#delete-container)
* [停止容器](http://dockerpool.com/static/books/shipyard_doc/api.html#stop-container)
* [重启容器](http://dockerpool.com/static/books/shipyard_doc/api.html#restart-container)
* [拓展容器](http://dockerpool.com/static/books/shipyard_doc/api.html#scale-container)
* [获取容器日志](http://dockerpool.com/static/books/shipyard_doc/api.html#get-container-logs)
## 引擎
* [引擎列表](http://dockerpool.com/static/books/shipyard_doc/api.html#get-engines)
* [引擎详情](http://dockerpool.com/static/books/shipyard_doc/api.html#get-engine)
* [增加引擎](http://dockerpool.com/static/books/shipyard_doc/api.html#post-engine)
* [删除引擎](http://dockerpool.com/static/books/shipyard_doc/api.html#delete-engine)
## Service Keys
* [Service Keys列表](http://dockerpool.com/static/books/shipyard_doc/api.html#get-service-keys)
* [增加Service Key](http://dockerpool.com/static/books/shipyard_doc/api.html#post-service-keys)
* [删除Service Key](http://dockerpool.com/static/books/shipyard_doc/api.html#delete-service-key)
## Webhook Keys
* [Webhook Keys列表](http://dockerpool.com/static/books/shipyard_doc/api.html#get-webhook-keys)
* [增加Webhook Key](http://dockerpool.com/static/books/shipyard_doc/api.html#post-webhook-key)
* [删除Webhook Key](http://dockerpool.com/static/books/shipyard_doc/api.html#delete-webhook-key)
## 事件
* [事件列表](http://dockerpool.com/static/books/shipyard_doc/api.html#get-events)
## 集群
* [集群详情](http://dockerpool.com/static/books/shipyard_doc/api.html#get-cluster-info)
## Docker中心
* [发布](http://dockerpool.com/static/books/shipyard_doc/api.html#deloyment)
## 身份验证
要使用Shipyard接口就必要要身份验证。要使用接口,需要创建一个[Service Key](http://dockerpool.com/service_keys.html)。所有的请求都必须在请求头里添加`X-Service-Key`。
~~~
curl -s -H "X-Service-Key: Lpc.usH1skelCuqwvjAtF.lJsWGwaKiwey2K" \
http://localhost:8080/api/cluster/info
{
"reserved_memory": 1024,
"reserved_cpus": 0.32,
"image_count": 17,
"engine_count": 1,
"container_count": 4,
"memory": 4096,
"cpus": 4
}
~~~
## 账户
### GET /api/accounts
获取账户列表
Request
`GET /api/accounts HTTP/1.1`
Response
~~~
[
{
"role": {
"name": "admin",
"id": "8c10fe3d-bf10-4bb9-ab4c-002502b71f13"
},
"password": "$2a$10$UvzJ8tssyF0Uvpaxmr06QOVbyJn5gTS4gDLapwo",
"username": "admin",
"id": "5f8e6567-9244-4fb2-bde9-24fb5e630b63"
},
{
"role": {
"name": "user",
"id": "ddc9a1b1-771b-4a07-807a-42cd027922a5"
},
"password": "$2a$10$EEkqHiOjC.018pnqr1giDe0ODVcGaDUC/2lXg",
"username": "test",
"id": "44a22dd3-ae74-4fe3-bdf6-58bbd0094f98"
}
]
~~~
### POST /api/accounts
创建账户
Request
~~~
POST /api/accounts HTTP/1.1
Content-Type application/json
{
"username": "foo",
"password": "bar",
"role": {
"name": "user"
}
}
~~~
Response
`HTTP/1.1 204 No Content`
### DELETE /api/accounts
删除账户
Request
~~~
DELETE /api/accounts HTTP/1.1
Content-Type application/json
{
"username": "foo"
}
~~~
Response
`HTTP/1.1 204 No Content`
## 角色
### GET /api/roles
获取角色列表
Request
`GET /api/roles HTTP/1.1`
Response
~~~
[
{
"name": "admin",
"id": "448ebe2d-89d9-412c-aab9-ad774d1ec78f"
},
{
"name": "user",
"id": "2243edf5-55f1-43ad-9ebb-c36c5233f007"
}
]
~~~
### GET /api/roles/
查看角色详情
Request
`GET /api/roles/admin HTTP/1.1`
Response
~~~
{
"name": "admin",
"id": "448ebe2d-89d9-412c-aab9-ad774d1ec78f"
}
~~~
### POST /api/roles
创建角色
Request
~~~
POST /api/roles HTTP/1.1
Content-Type application/json
{
"name": "test"
}
~~~
Response
`HTTP/1.1 204 No Content`
### DELETE /api/roles
删除角色
Request
~~~
DELETE /api/roles HTTP/1.1
Content-Type application/json
{
"name": "test"
}
~~~
Response
`HTTP/1.1 204 No Content`
## 容器
### GET /api/containers
容器列表
Response
~~~
GET /api/containers HTTP/1.1
[
{
"state": {
"started_at": "2014-09-12T00:48:23.824260519Z",
"pid": 5845,
"running": true
},
"ports": [
{
"container_port": 8080,
"port": 49159,
"proto": "tcp"
}
],
"engine": {
"labels": [
"local",
"dev"
],
"memory": 4096,
"cpus": 4,
"addr": "http://172.16.1.50:2375",
"id": "local"
},
"image": {
"restart_policy": {},
"labels": [
""
],
"type": "service",
"hostname": "cbe68bf32f1a",
"environment": {
"GOROOT": "/goroot",
"GOPATH": "/gopath"
},
"memory": 256,
"cpus": 0.08,
"name": "ehazlett/go-demo:latest"
},
"id": "cbe68bf32f1a08218693dbee9c66ea018c1a99c75c463a76b"
},
{
"state": {
"started_at": "2014-09-12T00:48:23.824260519Z",
"pid": 5846,
"running": true
},
"ports": [
{
"container_port": 8080,
"port": 49158,
"proto": "tcp"
}
],
"engine": {
"labels": [
"local",
"dev"
],
"memory": 4096,
"cpus": 4,
"addr": "http://172.16.1.50:2375",
"id": "local"
},
"image": {
"restart_policy": {},
"labels": [
""
],
"type": "service",
"hostname": "eca254ecd76e",
"environment": {
"GOROOT": "/goroot",
"GOPATH": "/gopath"
},
"memory": 256,
"cpus": 0.08,
"name": "ehazlett/go-demo:latest"
},
"id": "eca254ecd76eb9d887995114ff811cc5b7c14fe13630"
}
]
~~~
### POST /api/containers
发布容器
Request
~~~
POST /api/containers HTTP/1.1
Content-Type application/json
{
"name": "ehazlett/go-demo",
"cpus": 0.1,
"memory": 32,
"type": "service",
"hostname": "",
"domain": "",
"labels": ["local"],
"args": [],
"environment": {
"FOO": "bar"
},
"restart_policy": {
"name": "always"
},
"bind_ports": [
{
"host_ip": "10.1.2.3",
"proto": "tcp",
"container_port": 8080
},
{
"proto": "tcp",
"port": 80,
"container_port": 8080
}
],
"links": {
"redis": "db"
}
}
~~~
Response
~~~
HTTP/1.1 201 Created
[
{
"state": {
"started_at": "2014-09-12T00:48:23.824260519Z",
"pid": 5890,
"running": true
},
"ports": [
{
"container_port": 8080,
"host_ip": "10.1.2.3",
"port": 49172,
"proto": "tcp"
}
],
"engine": {
"labels": [
"local",
"dev"
],
"memory": 4096,
"cpus": 4,
"addr": "http://172.16.1.50:2375",
"id": "local"
},
"image": {
"restart_policy": {
"name": "always"
},
"labels": [
"local"
],
"bind_ports": [
{
"proto": "tcp",
"port": 49153,
"container_port": 8080
},
{
"proto": "tcp",
"port": 80,
"container_port": 8080
}
],
"links": {
"redis": "db"
},
"type": "service",
"memory": 32,
"cpus": 0.1,
"name": "ehazlett/go-demo"
},
"id": "4a5da04b8428e7241a9d9993699513d11b89948399dedfa12"
}
]
~~~
### GET /api/containers/
容器详情
Request
`GET /api/containers/3e532b HTTP/1.1`
Response
~~~
{
"state": {
"started_at": "2014-09-12T00:48:23.824260519Z",
"pid": 5891,
"running": true
},
"ports": [
{
"container_port": 8080,
"port": 49155,
"proto": "tcp"
}
],
"engine": {
"labels": [
"local",
"dev"
],
"memory": 4096,
"cpus": 4,
"addr": "http://172.16.1.50:2375",
"id": "local"
},
"image": {
"restart_policy": {},
"labels": [
"local"
],
"type": "service",
"hostname": "demo-1",
"environment": {
"GOROOT": "/goroot",
"GOPATH": "/gopath"
},
"memory": 256,
"cpus": 0.08,
"name": "ehazlett/go-demo:latest"
},
"id": "3e532b000891e90e93ca3781031e7c1ddb76d8378dfdfd3"
}
~~~
### DELETE /api/containers/
删除容器
Request
`DELETE /api/containers/3e532 HTTP/1.1`
Response
`HTTP/1.1 204 No Content`
## GET /api/containers//stop
停止容器
Request
`GET /api/containers/3e532/stop HTTP/1.1`
Response
`HTTP/1.1 204 No Content`
## GET /api/containers//restart
重启容器
Request
`GET /api/containers/3e532/restart HTTP/1.1`
Response
`HTTP/1.1 204 No Content`
## GET /api/containers//scale?count=
拓展容器到指定数目
Request
`GET /api/containers/3e532/scale?count=10 HTTP/1.1`
Response
`HTTP/1.1 204 No Content`
## GET /api/containers//logs
容器日志
Request
`GET /api/containers/3e532b/logs HTTP/1.1`
Response
~~~
listening on :8080
~~~
## 引擎
### GET /api/engines
引擎列表
Request
`GET /api/engines HTTP/1.1`
Response
~~~
GET /api/engines HTTP/1.1
[
{
"engine": {
"labels": [
"local",
"dev"
],
"memory": 4096,
"cpus": 4,
"addr": "http://172.16.1.50:2375",
"id": "local"
},
"id": "99095f5f-7579-4a70-9369-04ad73c21312"
}
]
~~~
### GET /api/engines/
引擎详情
Request
`GET /api/engines/local HTTP/1.1`
Response
~~~
GET /api/engines/local HTTP/1.1
{
"engine": {
"labels": [
"local",
"dev"
],
"memory": 4096,
"cpus": 4,
"addr": "http://172.16.1.50:2375",
"id": "local"
},
"id": "99095f5f-7579-4a70-9369-04ad73c21312"
}
~~~
### POST /api/engines
向集群中增加引擎
Request
~~~
POST /api/engines HTTP/1.1
Content-Type application/json
{
"id": "local",
"ssl_cert": "",
"ssl_key": "",
"ca_cert": "",
"engine": {
"id": "local",
"addr": "http://10.1.2.3:2375",
"cpus": 4.0,
"memory": 8192,
"labels": [
"local",
"dev"
]
}
}
~~~
Response
`HTTP/1.1 201 Created`
### DELETE /api/engines/
删除引擎
Request
`DELETE /api/engines/99095f5f-7579-4a70-9369-04ad73c21312 HTTP/1.1`
Response
`HTTP/1.1 204 No Content`
## Service Keys
### GET /api/servicekeys
service keys列表
Request
`GET /api/servicekeys HTTP/1.1`
Response
~~~
GET /api/servicekeys HTTP/1.1
[
{
"description": "test",
"key": "3pYgOl4K7vlkymoi1TMLIAQIJqcYhkGWY04."
},
{
"description": "demo",
"key": "Lpc.usH1skelCuqwvjAtF.lJsWGwaKiwey2K"
}
]
~~~
### POST /api/servicekeys
创建service key
Request
~~~
POST /api/servicekeys HTTP/1.1
Content-Type application/json
{
"description": "test key"
}
~~~
Response
~~~
{
"description": "test key",
"key": "zuoWetDKDRhPyUNRZro5cLo7yaFLKgzcqijW"
}
~~~
### DELETE /api/servicekeys
删除service key
Request
~~~
DELETE /api/servicekeys HTTP/1.1
Content-Type application/json
{
"key": "zuoWetDKDRhPyUNRZro5cLo7yaFLKgzcqijW"
}
~~~
Response
`HTTP/1.1 204 No Content`
## Webhook Keys
Webhook keys被用来发布镜像到Docker中心。
### GET /api/webhookkeys
webhook keys列表
Request
`GET /api/webhookkeys HTTP/1.1`
Response
~~~
GET /api/servicekeys HTTP/1.1
[
{
"key": "fc563339166b3c69",
"image": "ehazlett/go-demo",
"id": "d7c68d6f-65bc-4e0c-8134-8e281a6b4d9b"
}
]
~~~
### POST /api/webhookkeys
增加webhook key
Request
~~~
POST /api/webhookkeys HTTP/1.1
Content-Type application/json
{
"image": "ehazlett/redis"
}
~~~
Response
~~~
{
"image": "ehazlett/redis",
"key":"8d710a03c7d965aa"
}
~~~
### DELETE /api/webhooks/
删除webhook key
Request
`DELETE /api/webhooks/8d710a03c7d965aa HTTP/1.1`
Response
`HTTP/1.1 204 No Content`
# Info
### GET /api/cluster/info
查看集群信息
Request
`GET /api/cluster/info HTTP/1.1`
Response
~~~
GET /api/cluster/info HTTP/1.1
{
"reserved_memory": 768,
"reserved_cpus": 0.24,
"image_count": 6,
"engine_count": 1,
"container_count": 3,
"memory": 4096,
"cpus": 4
}
~~~
## Docker中心
### POST /hub/webhook/
通过Docker中心webhook自动部署。 将会在从Docker中心获取最新镜像并且重启集群中的所有镜像名称容器。查看如下例子:
要使自动部署生效,你可以在Docker中心的库设置中添加一个Webbook指向`http:///hub/webhook/`
Request
`POST /hub/webhook HTTP/1.1`
~~~
POST /hub/webhook HTTP/1.1
Content-Type application/json
{
"push_data":{
"pushed_at":1385141110,
"images":[
"imagehash1",
"imagehash2",
"imagehash3"
],
"pusher":"username"
},
"repository":{
"status":"Active",
"description":"my docker repo that does cool things",
"is_trusted":false,
"full_description":"This is my full description",
"repo_url":"https://registry.hub.docker.com/u/username/reponame/",
"owner":"username",
"is_official":false,
"is_private":false,
"name":"reponame",
"namespace":"username",
"star_count":1,
"comment_count":1,
"date_created":1370174400,
"dockerfile":"my full dockerfile is listed here",
"repo_name":"username/reponame"
}
}
~~~
Response
`HTTP/1.1 200 OK`
控制器
最后更新于:2022-04-01 00:52:13
这篇文档描述如何使用Shipyard的控制器。下面的示例假设你正在使用`shipyard/shipyard`的Docker镜像。
## 查看帮助
~~~
$> docker run shipyard/shipyard -h
Usage of /app/controller:
-listen=":8080": listen address
-rethinkdb-addr="127.0.0.1:28015": rethinkdb address
-rethinkdb-auth-key="": rethinkdb auth key
-rethinkdb-database="shipyard": rethinkdb database
~~~
## 侦听
允许改变侦听地址。不应该在运行容器中来改变。
## RethinkDB地址
连接RethinkDB的地址。使用`:`。
## RethinkDB数据库
Shipyard使用哪个RethinkDB数据库。
## RethinkDB验证密钥
连接RethinkDB时使用的验证密钥。
CLI使用
最后更新于:2022-04-01 00:52:11
这篇文档描述怎样使用Shipyard CLI(command line interface)来工作。
## 查看帮助
~~~
shipyard cli> shipyard help
NAME:
shipyard - manage a shipyard cluster
USAGE:
shipyard [global options] command [command options] [arguments...]
VERSION:
2.0.3
COMMANDS:
login login to a shipyard cluster
change-password update your password
accounts show accounts
add-account add account
delete-account delete account
containers list containers
inspect inspect container
run run a container
stop stop a container
restart restart a container
scale scale a container
logs show container logs
destroy destroy a container
engines list engines
add-engine add shipyard engine
remove-engine removes an engine
inspect-engine inspect an engine
service-keys list service keys
add-service-key adds a service key
remove-service-key removes a service key
extensions show extensions
add-extension add extension
remove-extension remove an extension
webhook-keys list webhook keys
add-webhook-key adds a webhook key
remove-webhook-key removes a webhook key
info show cluster info
events show cluster events
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help
--generate-bash-completion
--version, -v print the version
~~~
## 登录
登录Shipyard集群。将会保存授权信息到`~/.shipyardrc`。
~~~
shipyard cli> shipyard login
URL: http://localhost:8080
Username: admin
Password: **********
~~~
## 修改密码
只要登录了系统,你就可以使用 `change-password`来修改账户的密码。
~~~
shipyard cli> shipyard change-password
Password: **********
Confirm: **********
~~~
## 账户列表
列出所有Shipyard账户
~~~
shipyard cli> shipyard accounts
Username Role
admin admin
demo user
~~~
## 增加账户
使用命令 `add-account`。
### 可选项
* `--username,-u`:账户名称
* `--password,-p`:账户密码
* `--role,-r`:账户角色(admin/user)
~~~
shipyard cli> shipyard add-account -u demo -p demo123 -r user
~~~
## 删除账户
使用命令`delete-account`。
~~~
shipyard cli> shipyard delete-account demo
~~~
## 查看容器列表
查看集群所有容器列表使用 `containers`。
~~~
shipyard cli> shipyard containers
ID Name Host Ports
7b55a8eb9f57 redis:2.8.11 local tcp/49167:6379
3e532b000891 ehazlett/go-demo:latest local tcp/49155:8080
~~~
## 查看容器详情
~~~
shipyard cli> shipyard inspect 3e53
{
"id": "3e532b000891e90e93ca3781031e7c1ddb76d8378dfdfd3a34f",
"image": {
"name": "ehazlett/go-demo:latest",
"cpus": 0.08,
"memory": 256,
"environment": {
"GOPATH": "/gopath",
"GOROOT": "/goroot"
},
"hostname": "demo-1",
"type": "service",
"labels": [
"local"
],
"restart_policy": {}
},
"engine": {
"id": "local",
"addr": "http://10.1.2.3:2375",
"cpus": 4,
"memory": 8192,
"labels": [
"dev",
"local"
]
},
"ports": [
{
"proto": "tcp",
"port": 49155,
"container_port": 8080
}
]
}
~~~
## 发布容器
使用命令 `run`。
### 可选项
* `--name`:Docker镜像名称
* `--container-name`:容器名称
* `--cpus`:可使用的cpus
* `--memory`:可使用的内存单位MB
* `--type`:容器类型(service,host,unique)
* `--hostname`:容器主机名
* `--domain`:容器域名
* `--env`:设置容器环境变量
* `--link`:连接其他容器
* `--arg`:容器命令行参数
* `--vol`:容器挂载点(`/host/path:/container/path`或者`/container/path`)
* `--label`:用来调度的标签
* `--port`:容器暴露的端口(`/::`)
* `--publish`:暴露所有端口
* `--pull`:启动之前获取最新镜像
* `--count`:容器启动数量
* `--restart`:重启策略(失败时,总是,失败次数:5等等)
~~~
shipyard cli> shipyard run --name ehazlett/go-demo \
--cpus 0.1 \
--memory 32 \
--type service \
--hostname demo-test \
--domain local \
--link redis:db \
--port tcp/10.1.2.3:80:8080 \
--port tcp/::8000 \
--restart "on-failure:5" \
--env FOO=bar \
--label dev \
--pull
started 407e39dc1ccc on local
~~~
## 容器扩展
将扩展容器到想要的数量。
~~~
shipyard cli> shipyard scale --id 407e --count 10
scaled 407e39dc1ccc to 10
~~~
## 查看容器日志
显示容器的日志。
~~~
shipyard cli> shipyard logs 407e39
listening on :8080
~~~
## 销毁容器
杀掉和删除容器。
~~~
shipyard cli> shipyard destroy 407e
destroyed 407e39dc1ccc
~~~
## 查看引擎列表
显示集群上的引擎列表。
~~~
shipyard cli> shipyard engines
ID Cpus Memory Host Labels
local 4.00 8192.00 http://10.1.2.3:2375 dev,local
~~~
## 增加引擎
使用`add-engine`。
### 可选项
* `--id`:引擎id
* `--addr`:引擎地址(例如:[http://10.1.2.3:2375)](http://10.1.2.3:2375%EF%BC%89/)
* `--cpus`:引擎cpus
* `--memory`:引擎内存
* `--label`:调度使用的标签
* `--ssl-cert`:(可选)ssl证书地址
* `--ssl-key`:(可选)ssl key
* `--ca-cert`:(可选)ca证书地址
~~~
shipyard cli> shipyard add-engine --id demo --add http://10.1.2.3:2375 --cpus 4.0 --memory 4096 --label local --label dev
~~~
## 查看引擎详情
使用`inspect-engine`查看引擎详情。
~~~
shipyard cli> shipyard inspect-engine local
{
"engine": {
"labels": [
"local",
"dev"
],
"memory": 2048,
"cpus": 4,
"addr": "http://172.16.1.50:2375",
"id": "local"
},
"id": "a08b8518-e963-4eb5-959a-566bd270cd28"
}
~~~
## 删除引擎
使用 `remove-engine`从集群中删除引擎
~~~
shipyard cli> shipyard remove-engine demo
~~~
## 创建Service key
使用 `add-service-key`。
## 可选项
* `--description,-d`:key的描述
~~~
shipyard cli> shipyard add-service-key -d "test key"
created key: Z2uwezQGoaIcfiRSQBRbktrzdbFRWKlVTEry
~~~
## 查看Service key列表
使用 `service-keys`查看集群的service key 列表
~~~
shipyard cli> shipyard service-keys
Key Description
Z2uwezQGoaIcfiRSQBRbktrzdbFRWKlVTEry test key
~~~
## 查看集群信息
使用 `info`。
~~~
shipyard cli> shipyard info
Cpus: 4.00
Memory: 8192.00 MB
Containers: 2
Images: 5
Engines: 1
Reserved Cpus: 4.00% (0.16)
Reserved Memory: 3.52% (288.00 MB)
~~~
## 查看事件列表
使用`events`。
~~~
shipyard cli> shipyard events
Time Message Engine Type Tags
Sep 09 06:58:13 2014 container:6c07 local start docker
Sep 09 06:58:13 2014 container:6c07 local create docker
~~~
集群信息
最后更新于:2022-04-01 00:52:09
Shipyard提供查看集群状态信息。将会汇报所有集群的资源如CPUs和内存,容器数,镜像数,引擎数,以及CPUs和内存的使用率。
## 例子
### 查看集群信息
~~~
shipyard cli> shipyard info
Cpus: 4.00
Memory: 8192.00 MB
Containers: 2
Images: 5
Engines: 1
Reserved Cpus: 4.00% (0.16)
Reserved Memory: 3.52% (288.00 MB)
~~~
事件
最后更新于:2022-04-01 00:52:07
Shipyard记录所有的集群操作,例如容器的创建,启动,停止,service key的管理,引擎的管理等等。
## 例子
### 查看事件列表
~~~
shipyard cli> shipyard events
Time Message Engine Type Tags
Sep 09 06:58:13 2014 container:6c07 local start docker
Sep 09 06:58:13 2014 container:6c07 local create docker
~~~
Webhook keys
最后更新于:2022-04-01 00:52:04
Webhook keys用来连接Docker Hub。Webhooks主要作用是在Docker中心触发生成新的镜像和在Shipyard中重新部署。
## 工作流程
* Docker中心被触发构建新的Docker镜像
* Docker中心发送一个webhook提醒到Shipyard
* Shipy检查webhook key的授权
* Shipyard从Docker中心获取最新的镜像
* Shipyard停止和删除当前容器并且发布新的容器
## 使用webhook key
要使用webhook key,只需为Docker中心的镜像在如下地址添加一个webhook:`http:///hub/webhook/` 例如:`http://controller.example.com/hub/webhook/010f2af9db29f43a`。
## 例子
### 创建一个webhook key
~~~
shipyard cli> shipyard add-webhook-key --image ehazlett/go-demo
created key: 010f2af9db29f43a
~~~
### 查看webhook key列表
~~~
shipyard cli> shipyard webhook-keys
Image Key
ehazlett/go-demo 010f2af9db29f43a
~~~
### 删除webhook key
~~~
shipyard cli> shipyard remove-webhook-key 010f2af9db29f43a
removed 010f2af9db29f43a
~~~
Service Keys
最后更新于:2022-04-01 00:52:02
Service keys被用来接口调用。Service keys有全部的权限来操作Shipyard接口。
## 例子
### 创建Service key
~~~
shipyard cli> shipyard add-service-key -d "test key"
created key: Z2uwezQGoaIcfiRSQBRbktrzdbFRWKlVTEry
~~~
### 查看Service key列表
~~~
shipyard cli> shipyard service-keys
Key Description
Z2uwezQGoaIcfiRSQBRbktrzdbFRWKlVTEry test key
~~~
### 使用Service key
~~~
curl -s -H 'X-Service-Key: Z2uwezQGoaIcfiRSQBRbktrzdbFRWKlVTEry' http://localhost:8080/api/engines
[
{
"engine": {
"labels": [
"local",
"dev"
],
"memory": 2048,
"cpus": 4,
"addr": "http://10.1.2.3:2375",
"id": "local"
},
"id": "a08b8518-e963-4eb5-959a-566bd270cd28"
}
]
~~~
### 删除Service key
~~~
shipyard cli> shipyard remove-service-key Z2uwezQGoaIcfiRSQBRbktrzdbFRWKlVTEry
removed Z2uwezQGoaIcfiRSQBRbktrzdbFRWKlVTEry
~~~
容器
最后更新于:2022-04-01 00:52:00
在Shipyard中的一个容器就是一个简单的Docker容器。容器可以部署在一个或多个引擎。
部署一个容器的时候,有下列选项可用:
## Name
这是Docker镜像的名称,例如,`shipyard/shipyard`
## CPUs
给容器分配的CPU数量
## Memory
给容器分配的内存(单位MB)
## Type
在Shipyard中,一个容器可以是这些类型:`service`,`unique`,或者 `host`。
`service`类型会使用主机标签来调度容器。Shipyard只会在有这个标签的引擎上运行容器。
`unique`类型的容器只会在所有引擎上运行一个实例。这有助于调度的高可用性。
`host`类型将会运行在特定的主机上。对于特定的主机,可以使用下列的语法来启动:`--label host:`例如:`--label host:local`。这个容器就只会运行在引擎ID为:`local`的主机上。
## Hostname
容器的主机名
## Domain
容器的域名
## ENV
你可以指定多个 `--env`参数来给容器增加多个环境变量。使用`key=value`的格式。
## Arg
传递给容器的参数,使用`--arg`。同样的可以多次使用。
## Label
调用要使用到的标签
## Port
要暴露端口,使用下列语法:`--port /:`例如:`--port tcp/:8080 --port tcp/80:8080`。同样的可以多次使用。
## Pull
将会从registry中获取最新的镜像。
## Count
可以指定容器实例在集群中的启动数量。默认为1.
## 例子
### 发布一个容器
~~~
shipyard cli> shipyard run --name ehazlett/go-demo \
--cpus 0.1 \
--memory 32 \
--type service \
--hostname demo-test \
--domain local \
--env FOO=bar \
--label dev \
--pull
started 407e39dc1ccc on local
~~~
### 查看容器列表
~~~
shipyard cli> shipyard containers
ID Name Host Ports
407e39dc1ccc ehazlett/go-demo:latest local tcp/49166:8080
~~~
### 查看容器详情
~~~
shipyard cli> shipyard inspect 407e3
{
"ports": [
{
"container_port": 8080,
"port": 49166,
"proto": "tcp"
}
],
"engine": {
"labels": [
"local",
"dev"
],
"memory": 2048,
"cpus": 4,
"addr": "http://10.1.2.3:2375",
"id": "local"
},
"image": {
"restart_policy": {},
"labels": [
"local"
],
"type": "service",
"hostname": "407e39dc1ccc",
"environment": {
"GOROOT": "/goroot",
"GOPATH": "/gopath"
},
"memory": 256,
"cpus": 0.08,
"name": "ehazlett/go-demo:latest"
},
"id": "407e39dc1cccc675591c86306563e78be6de085745427656ad1"
}
~~~
### 销毁容器
~~~
shipyard cli> shipyard destroy 407e39
destroyed 407e39dc1ccc
~~~
引擎
最后更新于:2022-04-01 00:51:57
一个Shipyard集群包含一个或者多个“引擎”。一个引擎就是一个Docker后台程序,它提供socket(本地使用)或者供其他机器使用的TCP端口。除此之外再没有其他任何的代理或者安装远程程序来激活管理;仅仅只是通过Docker的接口。
Docker后台程序侦听TCP端口请参看[Docker文档](https://docs.docker.com/articles/basics/)在“Bind Docker to another host/port or a Unix socket”。
当一个引擎被添加到Shipyard中,你就可以为一个特殊的引擎定义资源限制了。在调度容器时会使用这些限制来确保引擎适应所有的请求。你可以使用SSL证书来保证安全通信。
## ID
每个引擎都必须有一个可以识别的标示符。
## 地址
这个地址是用来和引擎交互的。对于本地用户,你可以使用`unix:///path/to/docker.sock`。对于多机配置,使用非SSL端口`http://`或者基于SSL协议的`https://`
## 资源
每个引擎都应该定义对资源的限制。它们可以是CPU和内存(单位MB)。
## 标签
一个引擎可以有一个或多个标签。这些都是用来调度和决策容器的。
## SSL
一个引擎可以配置成使用SSL。参看[Docker文档](https://docs.docker.com/articles/https/)来运行SSL。
## 例子
### 增加引擎
~~~
shipyard cli> shipyard add-engine --id local \
--addr http://10.1.2.3:2375 \
--cpus 4.0 \
--memory 8192 \
--label dev \
--label local
~~~
你也可以使用Docker socket来添加引擎,这样的话就只能运行单机环境了。你也可以在Shipyard控制器运行时添加一个挂载项(`-v /var/run/docker.sock:/docker.sock`)
~~~
shipyard cli> shipyard add-engine --id local-socket \
--addr unix:///docker.sock \
--cpus 4.0 \
--memory 8192 \
--label dev \
--label local
~~~
### 查看引擎列表
~~~
shipyard cli> shipyard engines
ID Cpus Memory Host Labels
local 4.00 8192.00 http://172.16.1.50:2375 local,dev
~~~
### 查看引擎详情
~~~
shipyard cli> shipyard inspect-engine local
{
"engine": {
"labels": [
"local",
"dev"
],
"memory": 2048,
"cpus": 4,
"addr": "http://172.16.1.50:2375",
"id": "local"
},
"id": "a08b8518-e963-4eb5-959a-566bd270cd28"
}
~~~
### 删除引擎
~~~
shipyard cli> shipyard remove-engine a08b8518-e963-4eb5-959a-566bd270cd28
removed local
~~~
权限控制
最后更新于:2022-04-01 00:51:55
Shipyard支持多用户。你必须登录才能使用Shipyard集群。
注意:Shipyard将会在初次启动时自动创建一个管理用户。在登录之后你可以查看控制器的登录log。
## 账户
你可以通过管理员身份来创建多个用户以控制访问权限。
## 角色
在Shipyard中有两种角色:`admin`和`user`。 `admin`角色拥有全部的权限。`user` 角色除了不能管理账户和service keys之外其他都可以。
## 例子
### 创建一个账户
~~~
shipyard cli> shipyard add-account -u demo -p demo123 -r user
~~~
### 查看所有账户
~~~
shipyard cli> shipyard accounts
Username Role
admin admin
test user
~~~
### 删除账户
~~~
shipyard cli> shipyard delete-account demo
~~~
文档
最后更新于:2022-04-01 00:51:53
这份文档描述Shipyard是如何工作的。你可以使用[快速入门](http://dockerpool.com/quickstart.html)来部署Shipyard。
注意:这份文档展示的例子都是通过Shipyard命令控制接口面完成。你可以通过`shipyard/shipyard-cli`来运行一个Docker容器实例。例如:
~~~
docker run -it shipyard/shipyard-cli
~~~
## RethinkDB
RethinkDB用来保存账户,引擎,service key和拓展元信息。它不会保存任何Docker容器和镜像的信息。在`shipyard/rethinkdb`镜像中`/data`是数据挂载目录。
## 相关概念
查看下面的文档以了解详情。
* [权限控制](authentication)
* [引擎](engines)
* [容器](containers)
* [Service Keys](service_keys)
* [Webhook Kyes](webhook_keys)
* [事件](events)
* [集群信息](cluster_info)
## 使用
* [命令控制接口](cli)
* [控制器](controller)
## 接口
Shipyard提供功能强大的API来管理集群。
* [接口文档](api)
## 使用说明
默认情况下,控制器将在后台定期报告使用信息。包括引擎数量等等。它是后台运行的(包括ip和镜像名称的记录)。你可以在启动控制器时通过使用`-disable-usage-info`参数来禁用该特性。
简介
最后更新于:2022-04-01 00:51:51
# Docker集群管理
基于Docker集群管理工具[Citadel](https://github.com/citadel/citadel),Shipeyard使我们能够管理Docker的资源,包括容器,主机等等。
Shipyard与其他docker管理工具不同之处在于,它偏向于组件的组合性。Shipyard的核心部分是管理Dokcker(容器等)。但是它也可以通过拓展镜像的方式来添加诸如容器路由和负载均衡,中心化日志,更好的部署以及其他。你可以使用任何组件来适应你的需求。
![2015-06-25/558bc3ba59841](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-06-25_558bc3ba59841.png)
## Web UI
web接口提供了一些简单的基于Docker集群的管理。你可以通过简单的接口查看Docker集群和宿主引擎的使用率,创建和销毁容器,查看Docker集群通用事件和其他更多的。
## 命令行接口
Shipyard提供了一个强大的命令行接口。利用API,你完全可以管理所有的Docker集群。
![2015-06-25/558bc3c37e6d5](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-06-25_558bc3c37e6d5.png)
## 接口
Shipyard的核心是API。Shipyard构建于中心化的API。CLI和web UI都是使用API来提供所有的功能。通过使用service key,你可以直接通过Shipyard API来和Docker集群交互和自定义构建集群。
![2015-06-25/558bc3cbeb894](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-06-25_558bc3cbeb894.png)
## 更多信息
查看[文档](http://dockerpool.com/doc.html)来了解更多关于Shipyard是如何工作的。 查看[快速入门](quickstart)来获取Shipyard实例来开发。
## 帮助
如果你遇到任何问题,请毫不犹豫地在聊天室(#shipyard on Freenode)或者[GitHub](https://github.com/shipyard/shipyard)工程来获得帮助。
写在最前面
最后更新于:2022-04-01 00:51:48
我很荣幸来翻译和写一些关于shipyard的文档。
shipyard是docker集群ui,可以添加engine和常规操作docker,包括增删和伸缩。
我是[dockerpool](http://www.dockerpool.com/)的一员,有任何问题都可以通过我们的平台来获得帮助,或者邮件联系我,weilaihui@126.com。
Thinks
# Summary
* [写在最前面](index)
* [简介](introduction)
* [文档](doc)
* [权限控制](authentication)
* [引擎](engines)
* [容器](containers)
* [Service Keys](service_keys)
* [Webhook keys](webhook_keys)
* [事件](events)
* [集群信息](cluster_info)
* [CLI使用](cli)
* [控制器](controller)
* [接口](api)
* [快速入门](quickstart)