snowzach / doods2

API for detecting objects in images and video streams using Tensorflow
MIT License
232 stars 30 forks source link

Cannot change listening port #62

Closed diagonali closed 1 year ago

diagonali commented 1 year ago

I've tried changing the port value in my docker compose file (Running Doods2 in a Docker container) and also changing within the interface in portainer but no matter what I do, Doods2 keeps using port 8080.

What's the proper way to change the port Doods2 uses? Can this info be added to the documentation?

Thanks!

EDIT: I ended up console logging into the container and manually editing the config file (config.py). If anyone wants further instructions I can provide (I used Portainer)

snowzach commented 1 year ago

You can change the port by setting it in the configuration. It is documented...

server:
  host: 0.0.0.0
  port: 8080

However your issue sounds more like a docker one. If you want to listen on a different outside of your docker container, set it in your docker-compose file...

     ports:
        - 8085:8080

Will cause it to listen on port 8085 on your machine and forward it to port 8080 inside the docker container.

diagonali commented 1 year ago

You can change the port by setting it in the configuration. It is documented...

server:
  host: 0.0.0.0
  port: 8080

However your issue sounds more like a docker one. If you want to listen on a different outside of your docker container, set it in your docker-compose file...

     ports:
        - 8085:8080

Will cause it to listen on port 8085 on your machine and forward it to port 8080 inside the docker container.

Thanks for getting back to me, makes sense although I'm wondering if it's possible to have Doods2 use the internal port taken from the value specified in the docker compose file as it is with some other docker containers I'm using? It's just that if I re-pull a newer image of Doods2 at any point I think it will then overwrite the internal changes I've made.

My current docker-compose file for Doods2 is like this:

`services: doods2: container_name: doods2 restart: unless-stopped network_mode: host environment:

Even with ports:

Doods still continues to use port 8080 and fails in the logs. I'll try again with a fresh grab of the image.

Edit: I'm still getting "2022-10-21 15:29:17,798 - uvicorn.error - ERROR - [Errno 98] error while attempting to bind on address ('0.0.0.0', 8080): address already in use"

snowzach commented 1 year ago

Oh, you're using network_mode: host just add an environment variable SERVER_PORT=8087 and it should listen on a different port.

diagonali commented 1 year ago

That's great, thanks very much!