目录结构:
在根目录中,我运行docker-compose up --build
,并获得该站点正在运行的输出:
faq-site_1 | Configuration file: /srv/faq/_config.yml
faq-site_1 | Source: /srv/faq
faq-site_1 | Destination: /srv/faq/_site
faq-site_1 | Incremental build: disabled. Enable with --incremental
faq-site_1 | Generating...
faq-site_1 | done in 1.37 seconds.
faq-site_1 | Auto-regeneration: enabled for '/srv/faq'
faq-site_1 | LiveReload address: http://127.0.0.1:35729
faq-site_1 | Server address: http://127.0.0.1:4000/faq/
faq-site_1 | Server running... press ctrl-c to stop.
我使用docker exec -it c94ad3af91c9 bash
SSH到容器并执行了curl localhost:4000
。得到了HTML的预期结果。
我尝试从主机在http://127.0.0.1:4000上运行网站,Chrome浏览器失败,显示“ ERR_EMPTY_RESPONSE”。
我已将jekyll配置为在/faq
的子目录上运行。尝试访问
什么都没有。我总是从chrome那里得到这个:
Dockerfile:
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y --no-install-recommends apt-utils
RUN apt-get install -y ruby ruby-dev build-essential
RUN gem install jekyll bundler
RUN gem install jekyll-feed
RUN gem install jekyll-paginate
RUN gem install minima
RUN bundle -v
RUN gem -v
RUN jekyll -v
COPY ./ /srv/faq
WORKDIR /srv/faq
CMD ["bundle", "exec", "jekyll", "serve", "--livereload"]
docker-compose.yml:
version: '3'
services:
faq-site:
build: ./faq
volumes:
- ./faq:/srv/faq
ports:
- "4000:4000"
- "35729:35729"
答案 0 :(得分:3)
尝试绑定0.0.0.0
。这样您的站点就可以通过外部IP访问了。
CMD ["bundle", "exec", "jekyll", "serve", "--livereload", "--host", "0.0.0.0"]