Docker - jekyll/jekyll Container

Hello, how can i start the Jekyll Container?

https://hub.docker.com/r/jekyll/jekyll

What is the right input?

I have done:

docker pull jekyll/jekyll

Where can i find the the Dockerfile?

https://github.com/envygeeks/jekyll-docker/blob/master/README.md

Can you please help me?

steveng

Maybe those help … ?

your 1st Dockerapp

and @MichaelCurrin recipes

BTW, @MichaelCurrin ,

when using
export JEKYLL_VERSION=4.2

as per your recipe seems to fail on my computer

while
export JEKYLL_VERSION=3.8

does not on the jekyll build process.

this is due to not available v 4.2 ‘envygeeks-jekyll image’ may i guess ?

Though… docker … serve does show blank page on ( either 0.0.0.0 , locahost or 127.0.0.1) 4000 port on my browser.

What confuses me is that

jordi@anarres:/> ls /srv/jekyll
ls: cannot access ‘/srv/jekyll’: No such file or directory

dir. seems to empy …no _site folder ?

yet …

jordi@anarres:~/Docker/my-blog> ls _site/
404.html about assets feed.xml index.html jekyll

isn’t the Docker command supposed to ‘mount’ _site on /srv/jekyll folder ? what am i missing ?

  • log :point_up_2:

$ docker run --rm --volume=“$PWD:/srv/jekyll” -it jekyll/jekyll:$JEKYLL_VERSION jekyll serve --trace

Fetching minima 2.5.1
Installing minima 2.5.1
Bundle complete! 6 Gemfile dependencies, 28 gems now installed.
Bundled gems are installed into /usr/local/bundle
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux-musl]
Configuration file: /srv/jekyll/_config.yml
Source: /srv/jekyll
Destination: /srv/jekyll/_site
Incremental build: disabled. Enable with --incremental
Generating…
Jekyll Feed: Generating feed for posts
done in 0.479 seconds.
Auto-regeneration: enabled for ‘/srv/jekyll’
Server address: http://0.0.0.0:4000/
Server running… press ctrl-c to stop.

@jordila Whoops, thanks. I updated by guide to say 4.2.0 and tested it is valid.

@steveng There are two ways to run docker in a container.

Neither requires to run docker pull ..., unless you want to explicitly fetch it or get the latest version that is newer than the downloaded version.

Docker binary way

If you use of Docker is simple enough, you might be fine without using a Dockerfile at all.

So instead of

jekyll build --trace

You can do a drop-in replacement of a Docker command in there.

docker run --rm \
  --volume="$PWD:/srv/jekyll" \
  -it jekyll/jekyll:4.2.0 \
  jekyll build --trace

Of course that command is much longer, so you might want an alias for that, or setup docker-compose or Makefile. Plenty of ways to make sure you just type a short command.

As linked by @jordila , you can use my guide to setup a new Jekyll project or build an existing Jekyll project.
Jekyll recipes

That handles Ruby setup and bundle install for you! So you don’t even need Ruby or Bundler.
I don’t know if jekyll/jekyll includes Node, but jekyll/builder does.

Images available.

Then you can change the command passed to the container to be

...   -it jekyll/jekyll:4.2.0 \
-  jekyll build
+  npm install

@steveng

Dockerfile way

If you want to add some dependencies like Node, Postgres or Python along with Ruby and Jekyll in the jekyll/jekyll image, or have some other complex setup steps, then you a Dockerfile.

See Setup Jekyll with a Dockerfile

  • Dockerfile
    FROM jekyll/jekyll:4.2.0
    
    CMD ["jekyll", "--help"]
    ENTRYPOINT ["/usr/jekyll/bin/entrypoint"]
    

You can add more install packages there. In my guide I cover use of apk and apt-get.

Usage in the shell:

docker build --rm -t my_app:latest .
docker run --rm \
  -p 4000:4000   \
  --volume "$PWD:/srv/jekyll"   \
  my_app \
  jekyll serve --trace

@MichaelCurrin ,while running

docker run --name blog --rm  --volume="$PWD:/srv/jekyll"  -p 4000:4000  -it jekyll/jekyll:$JEKYLL_VERSION jekyll serve --trace

i’m now getting …

image

what am i missing ?

That’s a Jekyll server running with no content.

Stop the server.

Make a page e.g. index.md

---
---
# Hello world

Then start the server again.

Or use this to bootstrap a new project.

docker ... jekyll new .

Or clone my template.

git clone https://github.com/MichaelCurrin/jekyll-blog-demo.git
cd jekyll-blog-demo