Home > OS >  Share data between two docker containers sharing same network
Share data between two docker containers sharing same network

Time:08-05

I have a requirement to build two applications (in Golang), first application just receives data via UART and send it to the second application for processing, second application should receive the data and process.

I have already completed receiving data via UART in first application, now I'm looking for better way to get data from first module to second module. They both are running as docker containers and sharing same docker network.

I was thinking of creating rest API in second application and first application will simply send data with http call, but is there a better way to do? Any other option that can take advantage of docker network?

CodePudding user response:

In general, yes sockets are what you need. Plain TCP/UDP, HTTP server (RESTful API or not), gRPC, etc.

Or you start another container of a message queue (NATS, Kafka, RabbitMQ, etc), and write pub-sub logic. Or you can use a database.

Or you can mount a shared Docker volume between both containers and communicate via files.

None of these are necessarily unique to Golang and will work with any language.

  • Related