jekyll site in docker serving locally

2020-04-13 07:22发布

I'm trying to work with a jekyll site locally using vim and github, all within a docker container on my Windows 10 machine. I want to work in the container like it is a linux virtual machine with my Downloads directory as a volume and jekyll served on port 55.

My docker initialization is

docker container run -t -d -p 55:4000 -v ${PWD}:"/home/Downloads/" [container ID]

To start the jekyll site I run the following within the docker container

jekyll new my-awesome-site
cd my-awesome-site
bundle exec jekyll serve
...
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.

There is nothing showing up locally at 127.0.0.1:55 Chrome Error

What am I doing wrong?

Here is my Dockerfile

FROM: ubuntu:latest

RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y git && apt-get install -y software-properties-common
RUN apt-get install -y python-pip python-dev ruby-full build-essential
RUN pip install --upgrade pip
RUN apt-get install -y vim

# build ruby configuration
RUN mkdir gems \
    && echo '# Install Ruby Gems to /gems' >> /gems/.bashrc \
    && echo 'export GEM_HOME=/gems' >> /gems/.bashrc \
    && echo 'export PATH=/gems/bin:$PATH' >> /gems/.bashrc \
    && /bin/bash -c "source /gems/.bashrc"

# install jekyll
RUN gem install jekyll bundler

EXPOSE 4000

WORKDIR /home/work

docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                  NAMES
e25f6359ce49        572                 "/bin/bash"         28 minutes ago      Up 28 minutes       0.0.0.0:55->4000/tcp   loving_gagarin

标签: docker jekyll
1条回答
smile是对你的礼貌
2楼-- · 2020-04-13 08:03

Use bundle exec jekyll serve --host 0.0.0.0

This special host will tell jekyll to serve on all interfaces so that docker can relay the tragic to the outside world.

As a side note, don't use a port less than 1024, it may cause unexpected troubles.

查看更多
登录 后发表回答