Ron Yadgar
Ron Yadgar

Reputation: 397

Communication between two Docker containers

I'm using Docker with two containers. One of these is a simple server written in Python:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Flask Dockerized'

if __name__ == '__main__':
    app.run(debug=True,host='0.0.0.0')

The second one is simple client: i.e.

r = requests.get('http://localhost:5000')

How can I make them know each other, if both of them run in different containers?

Upvotes: 4

Views: 1814

Answers (1)

TheOriginalAlex
TheOriginalAlex

Reputation: 148

If you use a platform like Cycle you can use hostnames to connect containers via encrypted private networks.

Disclaimer: I'm a developer at Cycle.

P.S. Here's a link you can use to try it out: https://portal.cycle.io/signup?code=JO4J8BM

Upvotes: 1

Related Questions