How can a client located in a container communicate with a server that is not located in a container?

28 Views Asked by At

The host has a server that listens on local host port 6969 and a client that accesses this port. Communication occurs via a socket.

How can communication between the client and server be implemented if the client is stuffed into a docker container? How to correctly configure port forwarding?

I created a simple dockerfile:

FROM gcc:latest
COPY ./src/client.c /home
WORKDIR /home
RUN gcc client.c && ./a.out

I collected the image and launched it with the command:

docker run -p 127.0.0.1:9697:9697 -it clientcont

0

There are 0 best solutions below