When using docker and docker-compose, ports are binded and reserved at the beginning of the execution process. Since some applications outside the container can compete (and potentially crash) for the same ports, it would be interesting a solution to dynamically bind / unbind port for running docker containers.
One existing solution is is using variables to define the binding ports in docker-compose, but once started the container can not have any port binded or unbinded.
ports:
# Service1
- 14443:${PORTSERVICE1}
# Service2
- 13306:{PORTSERVICE2}
Is there any way to change ports binding dynamically after container initialization?