(Docker) Ghost silently crashes when uploading images

Original single container: https://pastebin.blairtech.org/?58ef299c00aa25cf#9t35xw3btopi7sBw6LZQAapGapUpZnQc1myH66RndYGk
Stack version: https://pastebin.blairtech.org/?6ddd2e8c531987ec#Ac9Azy8jFmgxLeR76NhD437fzDWJPE2YEUwwRHa9ZtHy

Why do you expose port 3306 in Ghost container (docker-compose)?

You haven’t configured MySQL database in your config.production.json file (I can see MySQL container in your docker-compose). Your Ghost container is using sqlite3 database. For MySQL it should look like:

"database": {
    "client": "mysql",
    "connection": {
      "host": "mysql",
      "user": "ghostusr",
      "password": "",
      "database": "ghostdata"
    }
  },

Also your ghost container needs to wait for mysql container. Some kind of wait-for-it.sh script is needed. See:
obraz

If the error is for uploading images, make sure that nginx conf file has:

  • client_max_body_size 50m;
  • remove client_body_buffer_size

To be honest, I don’t think I ever touched those files at all. They are as they were when the container was generated.

As for port 3306, I didn’t explicitly set that, it’s just how it came in that person’s stack. It doesn’t even actually set when you check the ports on the containers. Only 2368 is exposed.

Forgive me, but could you spell out where the nginx conf file would be inside the docker container and what I need to do? I’m still learning as I go. I’ll also redeploy using the docker compose stack you linked in the Medium article there.

Here is nginx conf file in this person’s repo:

I can see it is bind mount in nginx container (left path is on your host relative to docker-compose file, right path is on nginx container):
- ./nginx/conf/ghost.conf:/etc/nginx/conf.d/ghost.conf:z

It has:

  • client_max_body_size 10m;
  • client_body_buffer_size 128k;

Try to modify it to what I said in previous post and redeploy. Hope it helps

You can also simply check this:
docker container run --name ghost -p 80:2368 ghost
without any dependencies.

The command will end only when there is crash or you exit terminal or you enter CTRL + C and you’ll see all the logs:

You can enter Ghost on: http://localhost

If Ghost crashes the command will end and you’ll get all the log messages which you can paste in this topic:

But before running this please make sure that other containers do not block ports. Simply stop them and optionally remove them with:
docker container stop container-name
docker container rm container-name

I’ve got similar issue using apache.

From reading your solution it seems to be something buggy about chunking the post request through the proxy to nodejs/ghost?

I’ve tried removing apache and going straight to 2368.

How do I turn on DEBUG level logging - would that reveal anything?

root@ks359236:~/ghost# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8474a6de2520 ghost:alpine “docker-entrypoint.s…” 5 hours ago Up 17 minutes 0.0.0.0:2368->2368/tcp some-ghost
root@ks359236:~/ghost# cat docker-compose.yml
version: ‘3.6’

services:
some-ghost:
container_name: some-ghost
image: ghost:alpine
restart: always
ports:
- “2368:2368”
environment:
NODE_ENV: development
database__connection__filename: ‘/var/lib/ghost/content/data/ghost.db’
url: http://devnull.com.au
volumes:
- “./blog:/var/lib/ghost/content”
- “./config.production.json:/var/lib/ghost/config.production.json”
root@ks359236:~/ghost# uname -a
Linux ks359236 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64 GNU/Linux
root@ks359236:~/ghost#

Tried a whole bunch of different image files - they all crash nodejs -

The question is how can we see detailed logging information about what’s going on - what can we enable to dev debug this issue? Serverside.