Firstly thank you for your time. I can't get any date from an API in my docker container. Neverveless I can if I'm in the container with a curl command but not from postman or a curl command if I 'm not in the container I don't know why, somebody have a solution for me ? :(
I mapped the port, docker-compose ps :
python /bin/sh -c ./src/server.py - ... Up 0.0.0.0:9090->9090/tcp
Above my docker-compose file :
'''
# Docker Compose
version: "3"
# Docker Containers
services:
# python
python:
build: ./docker/python
working_dir: /root/app
command: ./src/server.py
environment:
- SERVER_PORT=9090
ports:
- 9090:9090
volumes:
- .:/root/app
- ./.bash-history/python:/root/.bash_history
'''
My python server :
'''
#!/usr/local/bin/python
import sys
sys.path.append('/root/app/python_modules')
from flask import Flask, json
companies = [{"id": 1, "name": "Company One"}, {"id": 2, "name": "Company Two"}]
api = Flask(__name__)
@api.route('/companies', methods=['GET'])
def get_companies():
return json.dumps(companies)
if __name__ == '__main__':
api.run(host='', port=9090, debug=True)
'''