Cannot load website live reload command into docker-compose.yml

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

One configuration is for live reloading in the container. 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 is my docker files.

#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:

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