Build and serve a Jekyll site in a docker container.
- Install Docker
- Clone or download this repo into
jekyll-docker
on your machine. - Have a Jekyll site on your computer or clone this NASA Web Design Standards starter site to your machine. Your jekyll site will need to have a
package.json
with astart
script that runsjekyll serve
like this - Open a bash terminal and
cd
tojekyll-docker
- Build a docker image named
jekyll-docker
by running this command:docker build -t jekyll-docker .
- Build and run the jekyll site within a docker container named
my_jekyll_site
(feel free to rename). Also you can choose a different name forjekyll-site
if you desire:docker run -it --name my_jekyll_site -p 127.0.0.1:4000:4000 -v /path/to/my/jekyll-site:/apps/jekyll-site jekyll-docker start jekyll-site
- Access your site at 127.0.0.1:4000 in a browser. Make changes to your site source files and the jekyll site running on http://127.0.0.1:4000/ will be updated automatically. Just refresh your browser to see the changes.
Ctrl+C
to stop the server- Next time you want to start the server:
docker start -ai `docker ps -a -q -f "name=my_jekyll_site"`
docker stop `docker ps -q -l`
docker rm $(docker ps -a -q)