strapi-docker icon indicating copy to clipboard operation
strapi-docker copied to clipboard

Self Hosted Docker container - docker compose exits container with code 0 and stops it

Open nooobcoder opened this issue 3 years ago • 6 comments

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 use 5532 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 of htop of my host machine when the compose 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)

image image

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.

image

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.

image

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)

nooobcoder avatar Jun 27 '21 12:06 nooobcoder

Move issue to correct repo

derrickmehaffy avatar Jun 28 '21 21:06 derrickmehaffy

@nooobcoder could you solve this issue or still need support?

ChristianHeimke avatar Oct 03 '21 05:10 ChristianHeimke

I have a similar issue and support would be appreciated!

System Details Ubuntu 18.04 LTS nodejs 16.13.2 npm 8.1.2

I run a normal docker container with docker run -it -p 1337:1337 -v `pwd`/project-name:/srv/app strapi/strapi as described from the README of the project. I get a similar output:

[...]
Starting your app...
Building your admin UI with development configuration ...

✔ Webpack
  Compiled successfully in 1.65m

navid@navid-Lenovo-G550:~/.../test$ 

The container just terminates after that. I have the same issue when installing via yarn or npx, that it says that it's building the admin UI and then just terminates after 'compiling successfully'. I just don't understand why it would also happen on docker.

Any help would be appreciated~

navidJadid avatar Jan 19 '22 21:01 navidJadid

Same issue - Exit code 0 Debian 11, using official v3 container, and also a v4 from @naskio

dreadedhamish avatar Sep 18 '22 09:09 dreadedhamish

I switched to another solution overall, but I think I read somewhere that old CPUs might not be supported by all build steps (due to their instruction sets). Mine was 13-14 years old… I don't have the source anymore though, so take it with a grain of salt

navidJadid avatar Jan 23 '23 16:01 navidJadid

Same issue here

MiqueiasGFernandes avatar Aug 09 '23 22:08 MiqueiasGFernandes