I have been going through Docker compose which will help in scaling multiple containers . But I have not taken a deep dive into the concepts of it . So at first , I started my Docker journey with creating two containers one as Client ( website) and other as the service . Now when I try to scale it using Docker compose there are some questions in my mind.
Thanks for your response . I have already achieved in client-server communication . Just hosted client and server in two different containers and the client was able to access the server container through the hostname:port it has exposed. In the Docker compose file there is
** - client**
As you said , manually the client container is able to connect to server container through port . If I use Docker compose what significance does the above step has. I think the app might work without having it mentioned , right ?
here is an example compose file from that link (it has two networks)
I think you will want to use expose on the service (server) side so that the client can access it.
(it does NOT need to be mapped to a host port)
App is working fine . But I have some things to be clarified
What is the difference between running Docker stack deploy -c docker-compose.yml servicename and docker-compose.yml up ?
If I increase the replicas of backend service and add
like its mentioned for web . So how will this work . If replica is set as 2 then will there be a common port 38080 which will load balance between the two ports ? I am trying to create 3 containers for web and 2 for backend and my understanding is 3 are mapped under 8999 and 2 backend containers will be mapped to 38080 . Please correct me if my understanding is wrong.
i think that the host port will have to be changed if multiple service containers are executed on the same host (as there is only one host port 38080…) I think docker inspect of the containers running will show the exact mapping.
now, if there is a unique host per service container, then the specified port would work. but this seems very heavy…