stegnerd
stegnerd

Reputation: 1189

Can't connect to docker endpoint even with docker-compose up successful

I am trying to learn how to containerize my flask api with docker. I am very new to docker, but from my understanding, I was able to build/update it. When I navigate to my route I get site can't be reached.

Any help would be greatly appreciated. Thank you.

Here is my yml file:

version: "3.6"
services:
  users:
build:
  context: ./services/users
  dockerfile: Dockerfile-dev
volumes:
  - "./services/users:/usr/src/app"
ports:
  - 5001:5000
environment:
  - FLASK_APP=project/__init__.py
  - FLASK_ENV=development
  - APP_SETTINGS=project.config.DevelopmentConfig

here is my dockerfile:

FROM python:3.6.5-alpine
WORKDIR /usr/src/app

COPY ./requirements.txt /usr/src/app/requirements.txt
RUN pip install -r requirements.txt

COPY . /usr/src/app

CMD python manage.py -h 0.0.0.0

and here is my powershell command and output:

docker-compose -f docker-compose-dev.yml up -d --build

enter image description here

upon further diagnosis I found this from the ps command enter image description here

I however cannot find in docker documentation what state of exit 2 means. Unless that is bash for misuse of shell builtin: http://www.tldp.org/LDP/abs/html/exitcodes.html. In that case I really don't know my problem and would appreciate any help!

Edit 3:

upon reading some github threads removing the -d flag from my command showed more information but it is still cryptic if anyone has an explanation for it:

enter image description here

Upvotes: 0

Views: 539

Answers (1)

vivekyad4v
vivekyad4v

Reputation: 14863

I guess new flask versions doesn't support -h anymore, try with --host -

Change CMD statement in Dockerfile to -

CMD python manage.py runserver --host 0.0.0.0

Ref - https://flask-script.readthedocs.io/en/latest/

Upvotes: 1

Related Questions