Docker status Exited (2)
I am trying to use a docker but I got some troubles with that.
docker-compose :
version: '3.7'
services:
web:
container_name: web
build:
context: .
dockerfile: Dockerfile
command: python manage.py runserver 0.0.0.0:8000
volumes:
- ./web/:/usr/src/web/
ports:
- 8000:8000
- 3000:3000
- 5432:9432
stdin_open: true
depends_on:
- db
db:
container_name: db
image: postgres:12.0-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=pass
- POSTGRES_DB=mydb
volumes:
postgres_data:
Dockerfile :
# pull official base image
FROM python:3.8.3-alpine
# set work directory
WORKDIR /usr/src/web
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install psycopg2 dependencies
RUN apk update
&& apk add postgresql-dev gcc python3-dev musl-dev
# install nodejs
RUN apk add --update nodejs nodejs-npm
# copy project
ADD . .
# install dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
I typed sudo docker-compose up -d --build
and the container was successfully created but when I type that :
docker ps -a
I got that :
ecf4382327f2 myservice_web "python manage.py ru…" 34 seconds ago Exited (2) 33 seconds ago web
97e742aa2f32 postgres:12.0-alpine "docker-entrypoint.s…" 35 seconds ago Up 34 seconds 5432/tcp db
I don’t understand why I got the status Exited (2)
Could you help me please ?
Thank you very much !
Source: Docker Questions