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.
I put my theme to a subfolder (like src
) in my theme git repository. And if I map this folder to a folder inside docker like /var/lib/ghost/content/themes/{theme_name}
then it works perfectly, without needing to upload anything in Ghost dashboard.
Based on @mheland’s docker-compose, here what I have now:
version: '3.7'
services:
ghost:
image: ghost:latest
restart: always
ports:
- 2368:2368
depends_on:
- ghost-db
environment:
database__client: mysql
database__connection__host: ghost-db
database__connection__database: ghost-dev-db
database__connection__user: ghost-dev-user
database__connection__password: abc123
NODE_ENV: development
GHOST_DEBUG: true
LOG_lEVEL: error
url: http://localhost:2368
volumes:
- ./src:/var/lib/ghost/content/themes/fluid
ghost-db:
image: mariadb:latest
restart: always
environment:
MYSQL_DATABASE: ghost-dev-db
MYSQL_USER: ghost-dev-user
MYSQL_PASSWORD: abc123
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- ghost-db:/var/lib/mysql
volumes:
ghost-db:
1 Like