docker中的jekyll站点在本地服务 [英] jekyll site in docker serving locally

查看:92
本文介绍了docker中的jekyll站点在本地服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用vim和github在本地使用jekyll网站,所有这些都在Windows 10计算机上的docker容器中。我想在容器中工作,就像它是一个Linux虚拟机,将我的Downloads目录作为卷,并将jekyll服务在端口55上。

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.

我的docker初始化是

My docker initialization is

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

要启动jekyll网站,我在docker容器中运行以下命令

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.

127.0.0.1:55

我在做什么错了?

这是我的Dockerfile

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


推荐答案

使用 bundle exec jekyll serve --host 0.0.0.0

此特殊主机将告诉jekyll服务

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

请注意,不要使用端口号小于1024的端口,否则可能会引起意外的麻烦。

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

这篇关于docker中的jekyll站点在本地服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆