Self Hosted Docker container - docker compose exits container with code 0 and stops it #306
Description
I have tried strapi with a postgres db and then too with default sqlite database, none of them worked either on my host machine.
Below are the docker-composes.
COMPOSE STACK WITH POSTGRES DB
version: '3'
services:
strapi:
image: strapi/strapi
environment:
DATABASE_CLIENT: postgres
DATABASE_NAME: strapi
DATABASE_HOST: postgres
DATABASE_PORT: 5832
DATABASE_USERNAME: strapi
DATABASE_PASSWORD: strapi
volumes:
- ./app:/srv/app
ports:
- '1337:1337'
depends_on:
- postgres
postgres:
image: postgres
ports:
- "5832:5432"
environment:
POSTGRES_DB: strapi
POSTGRES_USER: strapi
POSTGRES_PASSWORD: strapi
volumes:
- ./data:/var/lib/postgresql/data
COMPOSE STACK WITH sqlite DB (default)
version: '3'
services:
strapi:
image: strapi/strapi
volumes:
- ./app:/srv/app
ports:
- '1337:1337'
In either of the cases, the strapi app/admin dashboard server was exiting with status code 1.
I am attaching screenshots for relevance.
Also, FYI, there are no issues with postgres db and i can assure you that.
My Guesses
- Am i doing something wrong with the file permissions even by setting 777?
- My postgres default port
5432
is reserved and i need to use5532
as the port, am i doing something wrong there in the first example of the docker-compose example? - Are there still any dependencies issue in the app directory?
- Is my host machine running out of memory or other resources for which the app is not running and exiting with
code zero
. To be clear with this, I am attaching a screenshot ofhtop
of my host machine when thecompose stack
was being run. (I tried the same things on my AWS EC2 instance 7GB RAM DUAL CORE CPU there were no issues and the application ran without hicups btw i used 5432 as postgres port).
Hardware | Size/Space/Other |
---|---|
CPU | DUAL CORE |
RAM | 4GB (i guess that's enough) |
I am not jumbling up this thread with screenshots but i can share that in my experiments, this line was the common point of failure for the container to start and i do not why, i had also assigned perms of 777 to the folder and manually ran npm install
to install any missing dependencies.
strapi_strapi_1 exited with code 0
Also, if you are interested in checking out the contents of the app folder, here is a screenshot of it.
Someone please help me out in this case and I am really in a bad mood after allocating hours of work to set strapi up and end with failure.
Thank You,
Ankur Paul (nooobcoder)