[SOLVED] here
I am trying to create a simple HTTP server running in docker and seem to be failing. Here is the simplest app: test_http.jl
using HTTP
HTTP.listen() do req::HTTP.Request
req.target == "/" && return HTTP.Response(200, "OK")
end
and the dockerfile DockerfileJuliaHTTP
FROM julia:1.1.0
RUN julia -e 'using Pkg;Pkg.REPLMode.pkgstr("add HTTP ;precompile");using HTTP'
WORKDIR /root/code
ADD . /root/code
CMD julia -i test_http.jl
then I build the image like this
docker build -f DockerfileJuliaHTTP -t http-simple .
and start docker
docker run --rm -p 9090:8081 -it http-simple
I cannot access it using http://localhost:9090/ from the browser running on the host
Interestingly, if I login into that container. start julia and try to execute (note, it is 8081 port, since inside the container)
HTTP.request("GET","http://localhost:8081/")
I get those errors on the server
Error: error handling request
β exception =
β MethodError: no method matching (::getfield(Main, Symbol("##3#4")))(::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
β Closest candidates are:
β #3(!Matched::HTTP.Messages.Request) at /root/code/test_http.jl:6
β Stacktrace:
β [1] macro expansion at /root/.julia/packages/HTTP/GN0Te/src/Servers.jl:352 [inlined]
β [2] (::getfield(HTTP.Servers, Symbol("##13#14")){getfield(Main, Symbol("##3#4")),HTTP.ConnectionPool.Transaction{Sockets.TCPSocket},HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() at ./task.jl:259
β @ HTTP.Servers ~/.julia/packages/HTTP/GN0Te/src/Servers.jl:356
β Error: error handling request
β exception =
β MethodError: no method matching (::getfield(Main, Symbol("##3#4")))(::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
β Closest candidates are:
β #3(!Matched::HTTP.Messages.Request) at /root/code/test_http.jl:6
β Stacktrace:
β [1] macro expansion at /root/.julia/packages/HTTP/GN0Te/src/Servers.jl:352 [inlined]
β [2] (::getfield(HTTP.Servers, Symbol("##13#14")){getfield(Main, Symbol("##3#4")),HTTP.ConnectionPool.Transaction{Sockets.TCPSocket},HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() at ./task.jl:259
β @ HTTP.Servers ~/.julia/packages/HTTP/GN0Te/src/Servers.jl:356
β Error: error handling request
β exception =
β MethodError: no method matching (::getfield(Main, Symbol("##3#4")))(::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
β Closest candidates are:
β #3(!Matched::HTTP.Messages.Request) at /root/code/test_http.jl:6
β Stacktrace:
β [1] macro expansion at /root/.julia/packages/HTTP/GN0Te/src/Servers.jl:352 [inlined]
β [2] (::getfield(HTTP.Servers, Symbol("##13#14")){getfield(Main, Symbol("##3#4")),HTTP.ConnectionPool.Transaction{Sockets.TCPSocket},HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() at ./task.jl:259
β @ HTTP.Servers ~/.julia/packages/HTTP/GN0Te/src/Servers.jl:356
β Error: error handling request
β exception =
β MethodError: no method matching (::getfield(Main, Symbol("##3#4")))(::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
β Closest candidates are:
β #3(!Matched::HTTP.Messages.Request) at /root/code/test_http.jl:6
β Stacktrace:
β [1] macro expansion at /root/.julia/packages/HTTP/GN0Te/src/Servers.jl:352 [inlined]
β [2] (::getfield(HTTP.Servers, Symbol("##13#14")){getfield(Main, Symbol("##3#4")),HTTP.ConnectionPool.Transaction{Sockets.TCPSocket},HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() at ./task.jl:259
β @ HTTP.Servers ~/.julia/packages/HTTP/GN0Te/src/Servers.jl:356
β Error: error handling request
β exception =
β MethodError: no method matching (::getfield(Main, Symbol("##3#4")))(::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
β Closest candidates are:
β #3(!Matched::HTTP.Messages.Request) at /root/code/test_http.jl:6
β Stacktrace:
β [1] macro expansion at /root/.julia/packages/HTTP/GN0Te/src/Servers.jl:352 [inlined]
β [2] (::getfield(HTTP.Servers, Symbol("##13#14")){getfield(Main, Symbol("##3#4")),HTTP.ConnectionPool.Transaction{Sockets.TCPSocket},HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() at ./task.jl:259
β @ HTTP.Servers ~/.julia/packages/HTTP/GN0Te/src/Servers.jl:356
and after a while bunch of those
β @ HTTP.Servers ~/.julia/packages/HTTP/GN0Te/src/Servers.jl:356
β Warning: Connection Timeout: π 0βπ 0βπ 62s 127.0.0.1:8081:8081 β£16
β @ HTTP.Servers ~/.julia/packages/HTTP/GN0Te/src/Servers.jl:307
β Warning: Connection Timeout: π 0βπ 0βπ 63s 127.0.0.1:8081:8081 β£16
β @ HTTP.Servers ~/.julia/packages/HTTP/GN0Te/src/Servers.jl:307
β Warning: Connection Timeout: π 0βπ 0βπ 64s 127.0.0.1:8081:8081 β£16
β @ HTTP.Servers ~/.julia/packages/HTTP/GN0Te/src/Servers.jl:307
β Warning: Connection Timeout: π 0βπ 0βπ 69s 127.0.0.1:8081:8081 β£16
β @ HTTP.Servers ~/.julia/packages/HTTP/GN0Te/src/Servers.jl:307
β Warning: Connection Timeout: π 0βπ 0βπ 62s 127.0.0.1:8081:8081 β£16
β @ HTTP.Servers ~/.julia/packages/HTTP/GN0Te/src/Servers.jl:307
In general the docker setup functions fine (downloading bunch of images, I can connect to them, no problem, all works out of the box).
My real app, which uses Bukdu.jl
on top of HTTP.jl
experiences similar problem: cannot connect to container from the host PC. Although I get one step further: If I login into containerβs console and start running HTTP requests it runs all fine. Wonder if there is some configuration of the image/docker I am missing which seem to confuse HTTP.
I run
docker in Ubuntu 18.04.1 LTS inside VirtualBox on Windows 10