Run Jekyll on Docker

Viewed 460

I am trying to run latest version of jekyll on ubuntu-20.04 container. My container is below. I am able to build and I see I am able run the site on container. But now, I am unable to get the site exposed to outside world

Buidl is success

sudo docker build --tag jekyll_site:1.0 .

Run is also success, I see site is running on port 4000.

sudo docker run -p 80:4000 jekyll_site:1.0

FROM ubuntu:20.04
RUN apt update
RUN apt install -y ruby-full
RUN apt-get install -y build-essential zlib1g-dev
RUN gem install jekyll bundler

ENV HOME=/home/user
ENV GEM_HOME=/home/user/gems
ENV PATH=/home/user/gems/bin:$PATH
EXPOSE 4000
RUN ruby --version
RUN gem --version
WORKDIR /home/user/
RUN mkdir -p /home/user/my-awesome-site
RUN jekyll new my-awesome-site
RUN ls /home/user
WORKDIR /home/user/my-awesome-site
CMD bundle exec jekyll serve

Problem

Unable to get the site on port 80. Any thing I am missing here ?

2 Answers

After changing the CMD to series of strings I am able to run it.

CMD [ "bundle", "exec", "jekyll", "serve", "--force_polling", "-H", "0.0.0.0", "-P", "4000" ]

final version

FROM ubuntu:20.04
RUN apt update
RUN apt install -y ruby-full
RUN apt-get install -y build-essential zlib1g-dev
RUN gem install jekyll bundler

ENV HOME=/home/user
ENV GEM_HOME=/home/user/gems
ENV PATH=/home/user/gems/bin:$PATH
EXPOSE 4000
RUN ruby --version
RUN gem --version
WORKDIR /home/user/
RUN mkdir -p /home/user/my-awesome-site
RUN jekyll new my-awesome-site
RUN ls /home/user
WORKDIR /home/user/my-awesome-site
CMD [ "bundle", "exec", "jekyll", "serve", "--force_polling", "-H", "0.0.0.0", "-P", "4000" ]

This is how u anc version: "3.8"

services:
  site:
    image: jekyll/jekyll
    command: bash -c "jekyll new --force ./ && jekyll s"
    volumes: 
      - .:/srv/jekyll
    ports:
      - 4000:4000
    environment:
      JEKYLL_ENV: development
Related