prasmussen / glot-run

API for running code inside docker containers
https://run.glot.io/
MIT License
147 stars 48 forks source link

500 internal server error #18

Closed otave closed 7 years ago

otave commented 7 years ago

can't run code in a docker container. 2017-06-08 03:37:22 =ERROR REPORT====
Error in process <0.682.0> on node 'glot-run@127.0.0.1' with exit value:
{[{reason,{badmatch,{error,econnrefused}}},{mfa,{language_run_resource,accept_post,2}},{stacktrace,[{docker,container_create,1,[{file,"/glot-run/_build/default/lib/glot/src/docker/docker.erl" 2017-06-08 03:37:22 =ERROR REPORT====
Ranch listener http had connection process started with cowboy_protocol:start_link/4 at <0.682.0> exit with reason: {[{reason,{badmatch,{error,econnrefused}}},{mfa,{language_run_resource,acce ~

prasmussen commented 7 years ago

It looks like glot-run gets a connection refused when trying to connect to your DOCKER_API_URL. Have you configured you docker daemon to listen on a tcp socket?

otave commented 7 years ago

I have configured tcp socket.It worked last few weeks, but it ran into this problem after my server machine shut down because the power off.I`m so confused. Here is my test.

docker -H tcp://192.168.0.27:2375 run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 78445dd45222: Pull complete Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 Status: Downloaded newer image for hello-world:latest

Hello from Docker! This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.
  2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
  3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
  4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID: https://cloud.docker.com/

For more examples and ideas, visit: https://docs.docker.com/engine/userguide/

otave commented 7 years ago

`-module(docker_url).

-export([ container_create/1, container_start/2, container_remove/3, container_attach/3 ]).

container_create(BaseUrl) -> hackney_url:make_url(BaseUrl, <<"/containers/create">>, []).

container_start(BaseUrl, Id) -> hackney_url:make_url(BaseUrl, <<"/containers/", Id/binary, "/start">>, []).

container_remove(BaseUrl, Id, Params) -> hackney_url:make_url(BaseUrl, <<"/containers/", Id/binary>>, Params).

container_attach(BaseUrl, Id, Params) -> hackney_url:make_url(BaseUrl, <<"/containers/", Id/binary, "/attach">>, `Params).``

I find these code,and make a test like this. curl -H "Content-Type: application/json" -d '{"Image": "alpi ne", "Cmd": ["echo", "hello world"]}' -X POST http://192.168.0.27:2375/containers/create

result:

{"Id":"0488b71110bbe9217e7d7d572b987f6bb4e6b9322d45377963e1c2599bb9b014","Warnings":null} It turns that docker resful api works.

otave commented 7 years ago

I changed all of the ports,and restart it. it works again~