My virtualmachine's os is CentOS 7 and its docker version is 19.03.8. I create my own image python-image. I run the following codes to create a new container:
docker run -it -p 5555:5000 python-image /bin/bash
In the container, a python script named test.py is as follows:
# test.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def func():
    return "Hello docker!"
if __name__ == '__main__':
    app.run('0.0.0.0', port=5000)
Then I run python test.py and up the container.
In host shell, I run curl http://127.0.0.1:5555/ and it prints:
curl: (56) Recv failure: Connection reset by peer
I know that if specify --network as host when creating the container:
docker run -it --network host python-image /bin/bash
Starting the server and running curl http://127.0.0.1:5555/ in host will get the expected information. I wonder what should I do when keep default value of --network to get the same result.
 
    