Search code examples
jsoncommand-linedockerkubernetespydio

How to convert docker run command into json file?


I was wondering if anyone knows how to create a json file that would be the same as running:

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

I trying something very ambitious, I want to start my docker container in kubernetes-mesos cluster but can't seem to get the ports correct in the json file, alas I am still very new to this.

Thanks, TT

Here are my json files:

`

{
"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": {}
},

`

The pod and service both start and run ok.

However I am unable to access the running Pydio site on any of the master, minion or frontend ips.

Note: I am running a modified version of the this docker container:

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

My container has been tested and it runs as expected. You should see the login screen once it is running.

Please let me know if I can provide any other information.

Thanks again.


Solution

  • So, I finally got this to work using the following .json files:

    frontend-service.json

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

    frontend-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"}
    }
    

    I now have pydio with SSL running in a Mesos-Kubernetes env on GCE.

    Going to run some tests using more hostPorts to see if I can get more than one replica running on one host. At this point I can resize up to 3.

    Hope this helps someone.

    Thanks, TT