I set up a Ghost instance using Docker Compose and wrote a nice long blog post that I was really fond of. Then I restarted the ghost and db container and at first, I was getting Connection refused errors, and then suddenly it worked, saying that the database state requires initialization… Then it recreated all tables and now the few hours I put into the post and the instance itself are gone. Has there been any new updates that could cause this?
Thank you in advance.
I’m not a regular docker user, but my understanding is that you have to set it up correctly to actually persist the data past a restart. Maybe you didn’t? Sharing your docker compose file would be a good start for getting advice from the folks on the forum with more docker experience. :)
This usually happens when the Ghost container is online and the database container is still starting up. Ghost cannot connect to the database connection you provided.
The solution are health checks and dependencies between the container (e.g. the Ghost container can only start once the health check for the database container clears).
And yes, as @Cathy_Sarisky pointed out, this usually means you haven’t set up any volumes to persist the data. The data therefore only lives in the two containers you set up. Once you re-create these, the data is also gone.
That behaviour is not Ghost-specific but expected in a Docker environment.
Happy to solve these issues based on your compose file
Yup, that’s it. I didn’t set up a volume to persist the data. Shit happens, but I’ll be out of the blogging game for a while now
Store data (images/media) on your VPS/filesystem by mapping a directory.
volumes:
- /home/user/ghost-docker/content:/var/lib/ghost/content
gzip the /content dir from time to time and back up somewhere, end export all posts/settings from Ghost…
Members is a separate export, not included in the Ghost ‘Export content’
Sorry to hear that. But I’m glad you paid for that lesson with only one lost blog post, not several dozen!