1

I have Jekyll in docker. I'm running this command:

$ docker run --rm -ti -v $(pwd):/tmp/www -p 127.0.0.1:8080:4000 jcubic.pl
Configuration file: /tmp/www/_config.yml
            Source: /tmp/www
       Destination: /tmp/www/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 13.443 seconds.
 Auto-regeneration: enabled for '/tmp/www'
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.

But I can't access port 8080 on my local machine. Port is working because I can use:

$ docker run --rm -ti -v $(pwd):/tmp/www -p 127.0.0.1:8080:4000 jcubic.pl bash
bash-5.0# nc -lp localhost 4000
nc: bad local port 'localhost'
bash-5.0# nc -lp 4000
xxxx

$ nc localhost 8080
xxxx

If I run netcat and access 8080 from browser I got ERR_SOCKET_NOT_CONNECTED but when I run jekyll I've got ERR_CONNECTION_RESET.

If I run:

python -m SimpleHTTPServer 4000

I've got my website but it's broken because site url is wrong. How can I access Jekyll server inside docker?

jcubic
  • 61,973
  • 54
  • 229
  • 402
  • The server inside the container needs to be listening on the magic "all interfaces" address 0.0.0.0. If it listens only on (its own) 127.0.0.1 it's unreachable from outside the container. – David Maze Sep 13 '19 at 23:57

0 Answers0