che icon indicating copy to clipboard operation
che copied to clipboard

How to add a service witch runs on docker

Open mstavares opened this issue 8 years ago • 9 comments

Hi,

I have a dockerfile witch builds a docker image that runs a node service on port 8081. I would like to build and start this docker service when I start eclipse che.

How could I do this? I already tried to add my dockerfile inside of the dockerfiles directory expecting that my docker images was built, but is not working.

Thanks.

mstavares avatar Jul 13 '18 14:07 mstavares

@mstavares you can either build an image, push it to a registry and create a custom stack in Che, or create a custom stack from a Dockerfile

https://www.eclipse.org/che/docs/creating-starting-workspaces.html

ghost avatar Jul 13 '18 17:07 ghost

Hi @eivantsov, thanks for your reply.

Your solutions seems fit very well. Is it possible to get the docker IP that I'm launching in my workspace? I would be very happy if it was possible to set a static ip address for that docker image.

mstavares avatar Jul 18 '18 14:07 mstavares

@mstavares not sure I understood your question? Are you asking me to find out your host machine IP? :)

ghost avatar Jul 18 '18 14:07 ghost

@eivantsov for instance:

"frontend": {
              "installers": [
                "org.eclipse.che.exec", "org.eclipse.che.terminal"
              ],
              "servers": {
                "8081/tcp": {
                  "port": "8081",
                  "protocol": "http"
                }
              },
              "attributes" : {}
            }

Is it possible to define a static IPv4 address for this machine in the stack? This machine "frontend" runs a docker when I instantiate a workspace through this stack. I would like to know the IP address of this docker container.

mstavares avatar Jul 18 '18 14:07 mstavares

@mstavares no it is not possible

ghost avatar Jul 18 '18 14:07 ghost

@eivantsov is not possible to define it in the stack, but is it possible to define it somewhere else?

mstavares avatar Jul 18 '18 14:07 mstavares

Container gets some IP from Docker subnet. Che cannot set or predict it.

ghost avatar Jul 18 '18 15:07 ghost

Hi @eivantsov

Is it possible to set a static port?

Key PORT PROTOCOL RUNTIME 8081/tcp 8081 http URL: http://172.17.0.1:32962

For instance, I would like to set this port 32962 to this one 8081 even when I reboot my workspace.

mstavares avatar Jul 19 '18 14:07 mstavares

@mstavares no, Docker published exposed ports randomly from the ephemeral port range.

You may try single port policy though -e SINGLE_PORT=true. This way you will get a predictable URL that will not change across workspace restarts.

ghost avatar Jul 19 '18 14:07 ghost