How to migrate from traditional setup to Docker based Ghost?

Greetings, i was wondering if there is any tutorial or blog post that describes the process of moving the data (content folder, config.production.json file and db.sql file) from direct ubuntu installtion to a Docker setup consist of 2 containers (ghost and db).

Thanks in advance!

1 Like

The content folder is easy. Just copy it:

The config.production.json usually goes into environment variables.

You can, of course, also set a bind mount for the config.production.json:

The big problem will be the SQLite file. There is no direct way to convert that to MySQL. The “dialect” is quite different.

There are a few commercial products that can do it. I haven’t seen a “one click” or “one command” option that works for that.

The “easiest” would be to just migrate using the JSON exports. You will lose some data with this though (newsletter analytics, comments).

2 Likes

No, the db.sql is a file that i exported from MySQL with mysqldump not SQLite.

In that case, just use mysql:

When i try to remove the content folder from the container because i want to replace it with the backed up content folder i get this:

rm: can't remove 'content': Resource busy

Maybe because is being used

I feel like you might be missing some docker basics. Happy to help, but as with any self-hosting, I am of the opinion that you should understand the technology first, before putting a server into the WWW.

Containers are generally stateless. So, emptying the content folder should happen through the volume.

If you have a named volume, stop the Docker container, and remove the volume:

The next time you start the container with your Docker Compose (I assume) file, it will be created again.

If you have a bind mount, delete the content inside the content folder, not the content folder itself.

1 Like

Ohhh ok now i understood why the container broke after i added the files inside the container, ok jannis thanks a lot for your help.

1 Like

Which is the best way to stored data for Ghost in Docker? Volumes or Bind Mounts?

Matter of preference. Both have their advantages.

I personally prefer volumes since they are the more modern way, contained, and can be interacted with using the docker cli. Others prefer bind mounts, since there is a physical copy on the host, you can easily interact with.

1 Like

Better for speed, backup and ease of use?

For all of these: it depends.

Seriously, as with most things in this sphere, there is no one-size-fits-all answer. Are you familiar with the Docker CLI? Just use volumes. Are you more comfortable with native host file operations? Use a bind mount.

You can always try both and see for yourself. And change down the line.

3 Likes

Great question. The setup needs to be robust. Knock it around crash the database, rebuild from backup etc. I like nodejs websites in general because they’re so quick and easy to build and set up totally from scratch, fast and reliable and although I’m more familiar programming in php myself, that language is suffering from major long term performance and security issues.

Nodejs is all roll-your-own and build-it-yourself unless you do use Docker / Kubernetes etc., and even then, we’re entering a dangerous era of wholesale engineered fragility and things designed intentionally to fail, while communists and anarchists engage in polite debates about critical infrastructure.