如何将docker run命令转换为json文件?

时间:2015-05-15 15:30:21

标签: json command-line docker kubernetes pydio

我想知道是否有人知道如何创建一个与运行相同的json文件:

docker run -p 80:80 -p 443:443 starblade / pydio-v4

我尝试了一些非常雄心勃勃的东西,我想在kubernetes-mesos集群中启动我的docker容器,但似乎无法在json文件中获得正确的端口,唉我还是很新的。

谢谢, TT

以下是我的json文件:

`

{
"id": "frontend-controller",
"kind": "ReplicationController",
"apiVersion": "v1beta1",
"desiredState": {
"replicas": 3,
"replicaSelector": {"name": "frontend"},
"podTemplate": {
"desiredState": {
"manifest": {
"version": "v1beta1",
"id": "frontend-controller",
"containers": [{
"name": "pydio-v4",
"image": "starblade/pydio-v4",
"ports": [{"containerPort": 10001, "protocol": "TCP"}]
}]
}
},
"labels": {"name": "frontend"}
}},
"labels": {"name": "frontend"}
}

{
"id": "frontend",
"kind": "Service",
"apiVersion": "v1beta1",
"port": 80,
"port": 443,
"targetPort": 10001,
"selector": {
"name": "frontend"
},
"publicIPs": [
"${servicehost}"
]
}

Docker container Env info pulled from docker inspect command:

"Env": [
"FRONTEND_SERVICE_HOST=10.10.10.14",
"FRONTEND_SERVICE_PORT=443",
"FRONTEND_PORT=tcp://10.10.10.14:443",
"FRONTEND_PORT_443_TCP=tcp://10.10.10.14:443",
"FRONTEND_PORT_443_TCP_PROTO=tcp",
"FRONTEND_PORT_443_TCP_PORT=443",
"FRONTEND_PORT_443_TCP_ADDR=10.10.10.14",
"KUBERNETES_SERVICE_HOST=10.10.10.2",
"KUBERNETES_SERVICE_PORT=443",
"KUBERNETES_PORT=tcp://10.10.10.2:443",
"KUBERNETES_PORT_443_TCP=tcp://10.10.10.2:443",
"KUBERNETES_PORT_443_TCP_PROTO=tcp",
"KUBERNETES_PORT_443_TCP_PORT=443",
"KUBERNETES_PORT_443_TCP_ADDR=10.10.10.2",
"KUBERNETES_RO_SERVICE_HOST=10.10.10.1",
"KUBERNETES_RO_SERVICE_PORT=80",
"KUBERNETES_RO_PORT=tcp://10.10.10.1:80",
"KUBERNETES_RO_PORT_80_TCP=tcp://10.10.10.1:80",
"KUBERNETES_RO_PORT_80_TCP_PROTO=tcp",
"KUBERNETES_RO_PORT_80_TCP_PORT=80",
"KUBERNETES_RO_PORT_80_TCP_ADDR=10.10.10.1",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"PYDIO_VERSION=6.0.5"
],
"ExposedPorts": {
"443/tcp": {},
"80/tcp": {}
},

`

pod和服务都启动并运行正常。

但是我无法在任何主人,小兵或前端ips上访问正在运行的Pydio网站。

注意: 我正在运行此docker容器的修改版本:

https://registry.hub.docker.com/u/kdelfour/pydio-docker/

我的容器已经过测试,并按预期运行。 一旦它运行,您应该会看到登录屏幕。

如果我能提供任何其他信息,请告诉我。

再次感谢。

1 个答案:

答案 0 :(得分:1)

所以,我终于使用以下.json文件来实现:

前端-service.json

    {
  "id": "frontend",
  "kind": "Service",
  "apiVersion": "v1beta1",
  "port": 443,
  "selector": {
    "name": "frontend"
  },
  "publicIPs": [
    "${servicehost}"
  ]
}

前端-controller.json

{
  "id": "frontend-controller",
  "kind": "ReplicationController",
  "apiVersion": "v1beta1",
  "desiredState": {
    "replicas": 1,
    "replicaSelector": {"name": "frontend"},
    "podTemplate": {
      "desiredState": {
         "manifest": {
           "version": "v1beta1",
           "id": "frontend-controller",
           "containers": [{
             "name": "pydio-v4",
             "image": "starblade/pydio-v4",
             "ports": [{"containerPort": 443, "hostPort": 31000}]
           }]
         }
       },
       "labels": {"name": "frontend"}
      }},
  "labels": {"name": "frontend"}
}

我现在在GCE的Mesos-Kubernetes env中运行了带有SSL的pydio。

使用更多hostPorts运行一些测试,看看我是否可以在一台主机上运行多个副本。此时我可以调整到最多3个。

希望这有助于某人。

谢谢, TT