Hello guys, I’ve been trying to install Ghost for the past few days but whatever I do, I always run into the same issue, namely the mysql container seems to start up correctly, but the ghost container throws chown: /var/lib/ghost/content/db/mysql.sock: No such file or directory
I have no idea why it says /ghost/content/db when my db is persisted in /ghost/db.
I even tried using the bitnami/ghost image, but that runs into different issues. My docker-compose looks like this
In your Docker compose file, there were a few issues.
The one that led to the error message was the fact that you’re trying to put the database volume inside the Ghost content volume – not entirely sure why, but this causes issues.
I have separated the two volumes. Ghost has a ./content/ folder and the database has a ./db/ folder.
Changing that part made Ghost start up, but no database connection was possible. So, I had a look at the credentials you provided. In your Ghost environment, you specify a user “mysql” with password “some_root_pass”. However, you only set a root password in the mysql environment.
So, I took the liberty to create the database you specified, as well as the user and a password in the db-service.
Now, I added a health check that I am running on some production sites. The mysql container needs longer to start up (especially the first time you run it) than the Ghost container. This will cause the Ghost container to crash until the MySQL container is available.
The healthcheck periodically checks whether the database is available. I then added the health check to the depends_on property in your Ghost container, so it only starts once the database is available.
Here is the final docker-compose.yml that I managed to successfully start on my local machine:
You might need to remove the content of the volumes and completely destroy the containers, then try again. When I cleared all data on my local machine and ran docker compose up -d everything worked.