Running Ghost Blog with Docker in Development Mode


Ghost is a popular open-source publishing platform designed for creating and managing blogs. With Docker, you can easily set up and run Ghost in a containerized environment. In this guide, we’ll show you how to run Ghost in development mode using Docker.

Step 1: Install Docker
Before proceeding, ensure you have Docker installed on your system. If you haven’t installed Docker yet, follow the official Docker installation instructions for your operating system.

Step 2: Run Ghost Blog Container
Run the following command to create and start the Ghost blog container in development mode:

docker run -d --restart always --name ghost -p 2368:2368 -v ghost_data:/var/lib/ghost/content -e NODE_ENV=development ghost:latest

Explanation of options used:

  • -d: Run the container in the background (detached mode).
  • --restart always: Configure the container to automatically restart if it stops unexpectedly.
  • --name ghost: Assign the name “ghost” to the container for easy management.
  • -p 2368:2368: Map port 2368 from the container to the host system. This allows you to access the Ghost blog from http://localhost:2368.
  • -v ghost_data:/var/lib/ghost/content: Create a Docker volume named “ghost_data” and mount it to the /var/lib/ghost/content directory inside the container. This volume allows you to persist Ghost blog data, including posts and images.
  • -e NODE_ENV=development: Set the environment variable NODE_ENV to “development.” This tells Ghost to run in development mode, which provides additional debugging information and enables certain development features.

Step 3: Access Ghost Blog
Once the Ghost blog container is running, you can access the blog by opening a web browser and navigating to http://localhost:2368. From here, you can set up and customize your Ghost blog.

Step 4: Clean Up (Optional)
If you want to stop and remove the Ghost blog container while preserving the data, use the following commands:

docker stop ghost
docker rm ghost

You’ve successfully set up and run the Ghost blog in development mode using Docker. Ghost’s development mode allows you to test and experiment with your blog’s configuration and theme without affecting the production environment. Docker provides a portable and isolated environment for running Ghost, making it easy to manage and deploy your blog.

Happy blogging!

You may also like...