Docker Community Forums

Share and learn in the Docker community.

Accessing container port from host fails

docker

(Toogley) #1

Hey.

I have this Dockerfile:

FROM fedora:latest 

RUN dnf update --assumeyes 
RUN dnf install --assumeyes ruby-devel
RUN dnf install --assumeyes rubygems
RUN dnf install --assumeyes rubygems-devel
RUN dnf install --assumeyes libffi
RUN dnf install --assumeyes libffi-devel

# jekyll things 
RUN  dnf install --assumeyes rubygem-jekyll
RUN  dnf install --assumeyes rubygem-rb-inotify
RUN  gem install jekyll-gist
RUN  gem install jekyll-paginate
RUN  gem install jekyll-sass-converter
RUN  gem install jekyll-sitemap 

# tools
RUN dnf install --assumeyes git

RUN git clone https://github.com/neomutt/neomutt.github.io.git
EXPOSE 4000

RUN ["/bin/bash"]

After these steps:

$ docker build -t fedora-jekyll .
$ docker run --publish-all=true -it fedora-jekyll /bin/bash
[root@ac7784beadbb /]# cd neomutt.github.io/ && jekyll serve
Configuration file: /neomutt.github.io/_config.yml
Configuration file: /neomutt.github.io/_config.yml
            Source: .
       Destination: ./_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
    Liquid Warning: Liquid syntax error (line 18): Unexpected character / in "{{https://github.com/p.nick}}" in feed.xml
                    done in 6.244 seconds.
 Auto-regeneration: enabled for '.'
Configuration file: /neomutt.github.io/_config.yml
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.

I can’t access http://127.0.0.1:4000/ from the host:

$ ping http://127.0.0.1:4000/
ping: http://127.0.0.1:4000/: Name or service not known

How can i fix that?