# How do I live reload in a Linux Docker container?

**URL:** <https://talk.jekyllrb.com/t/how-do-i-live-reload-in-a-linux-docker-container/9216>\
**Category:** Help\
**Created:** [May 28, 2024, 10:57am UTC](https://talk.jekyllrb.com/t/how-do-i-live-reload-in-a-linux-docker-container/9216 "2024-05-28T10:57:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jords287](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jords287](https://talk.jekyllrb.com/u/jords287)\
**Post date:** [May 28, 2024, 10:57am UTC](https://talk.jekyllrb.com/t/how-do-i-live-reload-in-a-linux-docker-container/9216/1 "2024-05-28T10:57:56Z")

</div>

I cannot load my website when implementing live reloading in Jekyll with my docker container. What I wanted to do was toggle between two different commands in my compose file.

One configuration is for live reloading in the container.

```console
command: jekyll serve --watch --force_polling

```

The other (which is commented out) is to live reload and display unpublished blogs with the Front Matter Published property set to False. I wanted to switch between them.

But all they do is prevent the website from loading at `localhost:4000` when I run `docker compose up -d`

I have removed the Jekyll cache files, reinstalled the gem files with `bundle install` and compiled it successfully with the dependencies installed on my WSL2 Ubuntu instance.

If it helps here are my docker files.

```console
#Dockerfile

# Use the official Ruby image
FROM ruby:3.0

# Install Jekyll and Bundler
RUN gem install jekyll bundler

# Set the working directory to /app
WORKDIR /app

# Copy your Jekyll project files into the container
COPY . .

# Install dependencies
RUN bundle install

# Expose port 4000 (Jekyll default)
EXPOSE 4000

# Command to run Jekyll
CMD ["jekyll", "serve", "--host", "0.0.0.0"]

```

Here’s my docker-compose.yml file:

```console
version: "3.9"
services:
  jekyll:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "4000:4000"
    volumes:
      - .:/app

command: jekyll serve --watch --force_polling
#command: jekyll servey --unpublished --watch --force_polling

```

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [May 28, 2024, 3:13pm UTC](https://talk.jekyllrb.com/t/how-do-i-live-reload-in-a-linux-docker-container/9216/2 "2024-05-28T15:13:26Z")

</div>

I don’t see watch as a jekyll command, where did you see that?

The command is --livereload or -l

also your second command has a spelling issue.

---

<div class="post-metadata">

**Author:** ![BillRaymond](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/billraymond/32/5963_2.png) [@BillRaymond](https://talk.jekyllrb.com/u/BillRaymond)\
**Post date:** [May 30, 2024, 3:36pm UTC](https://talk.jekyllrb.com/t/how-do-i-live-reload-in-a-linux-docker-container/9216/3 "2024-05-30T15:36:07Z")

</div>

Along with @rdyar’s statements, I see some potential challenges here. For example, I do not see you running `bundle install` or `bundle update` to install any packages before running your Jekyll project.

I successfully run Docker on my computer, but I use Dev Containers, which (in my opinion) are easier to develop with. Even if you do not want to use Dev Containers, you will learn the steps to run Docker containers on your computer with this video I created:

[![](https://canada1.discourse-cdn.com/flex030/uploads/jekyllrb/original/2X/8/894c457a0c71ea5987fd6d90f76ba54d755cd0ef.jpeg "🎉 Develop GitHub Pages locally in a Ubuntu Docker Container (latest)") ](https://www.youtube.com/watch?v=zijOXpZzdvs)

---

<div class="post-metadata">

**Author:** ![jords287](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jords287](https://talk.jekyllrb.com/u/jords287)\
**Post date:** [June 2, 2024, 12:42am UTC](https://talk.jekyllrb.com/t/how-do-i-live-reload-in-a-linux-docker-container/9216/4 "2024-06-02T00:42:39Z")

</div>

Hi people,

Sorry for the slow response. I already know who you are @BillRaymond, and I have to say your video convinced me to stop using WSL 2 and transition to Dev Containers since there’s no generic Linux tool I use in WSL 2 anyway. Thanks for your video, I know it was a colossal amount of effort!

@rdyar thanks for pointing that embarrassing mistake out. I saw --watch used in a tutorial. As for --livereload or -l the reason I used --force\_polling instead is that I heard it is an alternative that works better with docker volumes. I will try both to see how I go thanks.

---

<div class="post-metadata">

**Author:** ![BillRaymond](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/billraymond/32/5963_2.png) [@BillRaymond](https://talk.jekyllrb.com/u/BillRaymond)\
**Post date:** [June 4, 2024, 12:22am UTC](https://talk.jekyllrb.com/t/how-do-i-live-reload-in-a-linux-docker-container/9216/5 "2024-06-04T00:22:59Z")

</div>

Hi @jords287, glad you got it all sorted out and thank you for the kind words!
