Jekyll on Docker

Good articles on running Jekyll in Docker:

Windows (PowerShell)

docker run --rm --volume="${PWD}:/srv/jeykll" --volume="${PWD}\vendor\bundle:/usr/local/bundle" -p 4000:4000 -it jekyll/jekyll /bin/bash
  • --rm removes the container soon as it finishes

  • --volume="${PWD}:/srv/jekyll" maps the current directory to /srv/jekyll in the container

  • --volume:"${PWD}\vendor\bundle:/usr/local/bundle" maps to local directory where gems are installed to a directory in the container so that the gems are "cached"

  • -p 4000:4000 maps port 4000 on localhost to port 4000 in the container

  • -it makes the shell interactive

  • jekyll/jekyll selects the correct image and pulls it down if it hasn't been pulled down before

  • /bin/bash is the command to execute in the container

Linux (BASH)

docker run --rm -v $PWD:/srv/jekyll -v $PWD/vendor/bundle:/usr/local/bundle -p 4000:4000 -it jekyll/jekyll /bin/bash