Use the Ghost Docker image for your theme's dev environment

Is it possible to use the official Docker image of Ghost to set up my theme dev environment.

My internet connection is quite bad, doing a fresh install of ghost with the CLI is such a bad experience (Takes easily an entire day if succeeding at all). The Docker image on the other hand… So much better.

I tried to no avail with this command:

docker run -d -e NODE_ENV=development -p 3001:2368 -v $PWD:/var/lib/ghost/current/content/themes/customtheme ghost

I made a symbolic link inside the container.

Is there a correct way to get this done or is it at all possible?

Hi, assuming you’re on Windows? Do you have a decent windows machine with 16+GB ram?

  • Use WSL2 Windows Subsystem for Linux with Debian/Ubuntu.
  • Install Docker Desktop for Windows running in/for wsl2 (amazing tech…)
  • Launch Ghost from a Docker Compose in WSL2, mapping the ghost-docker /content directory to a wsl2 directory, accessible in Windows Explorer (!)
  • Bob’s your uncle.

Here’s a docker compose for local dev

1 Like

I am using Linux. I have 16+GB RAM.

The docker compose seems to be aimed for production. Still, same issue

Thanks a lot for taking the time to answer me.

Hi Jose,
on Linux things are easier, and the Docker Compose is from my dev environment.

Map the Docker-Ghost content folder to a Linux directory and you’re all set.
Create the ghost-content folder, and you also need to set the url: parameter

volumes: 
      - /home/jose/ghost-content:/var/lib/ghost/content

Upload a theme and edit the theme files in…

/home/jose/ghost-content/content/themes/

Seems like it doesn’t works. I get this error:
chown: cannot dereference ‘/var/lib/ghost/content/themes/blog-theme’: No such file or directory
Maybe it is a problem with the image version?

Suggesting reset of docker environment, export the Ghost content as json (Labs…) and delete all containers and volumes…

docker-compose down
docker rm -f $(docker ps -a -q)
docker volume rm $(docker volume ls -q)

then try again with the external /content directory…

You will have to import your content-json and upload the theme again.