Getting Started

Install Docker Desktop for Mac:

  • Download Docker Desktop from the Docker website.
  • Follow the installation instructions provided on the website.

Start Docker Desktop:

  • Open Docker Desktop from your Applications folder and make sure it's running.

Open Terminal:

  • Open the Terminal application on your Mac.

Pull the Ghost Image:

  • In the Terminal, run the following command to pull the latest Ghost image from Docker Hub:
docker pull ghost:latest

Run the Ghost Container:

  • Run the following command to start a new Ghost
docker run -d --name ghost-blog -p 2368:2368 ghost:latest
  • This command starts a new Ghost container named ghost-blog and maps port 2368 on your local machine to port 2368 in the container.

Access Ghost:

  • Open your web browser and navigate to http://localhost:2368. You should see your Ghost blog running.
    • You can stop the container with:
codedocker stop ghost-blog
    • You can start it again with:
docker start ghost-blog
    • To remove the container, use:shCopy code
docker rm ghost-blog

Editing Your Theme and Copying to Docker

You can edit your theme locally then copy over the work to the theme directory in Docker. Here are two examples:

Example 1 - Docker Theme to Local Theme

docker cp ghost-blog:/var/lib/ghost/content/themes/<mythemename> ~/Downloads/

Example 2 - Local Theme to Docker Theme

cp ~/Downloads/solo ghost-blog:/var/lib/ghost/content/themes/

Troubleshooting

Ensure Ghost Can Connect to the Database

If the database is in a container, 127.0.0.1 might not be the correct host address from the perspective of the Ghost container. Use Docker networking to allow communication between containers.

  1. Create a Docker Network: Create a network to allow the containers to communicate:
docker network create ghost-network
  1. Connect Containers to the Network: Connect both the Ghost and MySQL containers to this network:
docker network connect ghost-network ghost-db
docker network connect ghost-network ghost-blog