binding ports with docker-compose and run configurations

Answered

Working in a Django project I may have many Python processes running at once: a shell process, a celery worker, tests, in addition to the Django server.

The project's Python Interpreter is set to use Docker Compose.

If I point it at a docker-compose service that binds no ports, I cannot connect to the Django server from my web browser.

If I add a `ports` section to that docker-compose service, the first thing I start grabs that port, and when I attempt to run other things they fail with 

```

Error running 'run server'
com.intellij.docker.remote.run.runtime.WrappedInternalServerErrorException: com.github.dockerjava.api.exception.InternalServerErrorException: {"message":"driver failed programming external connectivity on endpoint proj_service_1 (...): Bind for 0.0.0.0:8443 failed: port is already allocated"}

```

How is this supposed to work?

0
1 comment

Am I right that you have at least two Run configurations in PyCharm: Django server and Django tests? Could you please explain in details how do you start the other things ("a shell process, a celery worker")?

In theory you could set several port bindings in ports section for your "web server" service in the docker-compose.yml and use different ports in different places.

I should notice that each PyCharm Run configuration (including Django server and Django tests) use docker-compose up command which results in inability to run server and tests in parallel. But you can use Django console in PyCharm along with running server or tests because it uses docker-compose run.

0

Please sign in to leave a comment.