Changed from Docker-run to Docker-compose; Unpredictable behaviour regarding Inter-Container-Network-Communication

Viewed 82

After two days trying to figure it out by myself, I've decided to present my problem to the public.

We use Docker to setup our Test-Environment. We're testing a Java-Client-Server-Application. In the past the application was just meant to run in a "Single-site"-Configuration (1 Server and x Clients). Now we are upgrading the application to a "Multi-Site"-Configuration (x Servers and y Clients).

For this reason we changed from Docker-run to Docker-compose to easily build-up a "complex" network.

With Docker-run we encountered no problems.

With Docker-compose we are able to set-up a network like we wish (e.g. 4 servers with to 2 clients each). We are also able to reach every container via SSH and VNC and we are able to ping between each container within there own networks.

Problem: Our Java-clients are not able to connect to there servers. Even though they're in the same network.

And now the really frustrating part:
Maybe 1 client out of 5 is able to connect to his server. Till now i would call it a complete random behavior. It's not always the 5th container which works or the same network-configuration. Also a 1-Server-1-Client-Network doesn't work always. The last one maybe after the 5th attempt.

First I thought that I had to expose the RMI-Ports too, but that didn't work. Later I opened all ports, just to the sure, but that didn't work either. Regarding to the Docker-Docs it's also not necessary to do that. Furthermore it would also not explain the behavior that it works sometimes. My problem is also that I didn't setup the original Docker-Run-Configuration, maybe I missed some important part here.

Maybe someone of you can point me in the right direction.

Regards, Kai

Example Picture for a Multi-Site-Configuration

Code of the automatically created yaml-File:

version: '2.1'
services: 
    foo_server_1: 
        image: foo_server:latest
        mem_limit: 1g
        memswap_limit: 2g
        container_name: foo_server_1
        ports: 
            - "22"
            - "4567"
        networks: 
            - foo_server_network
            - client_net_1
    foo_client_1_1: 
        image: foo_client:latest
        mem_limit: 1g
        memswap_limit: 2g
        links: 
            - foo_server_1:server
        container_name: foo_client_1_1
        ports: 
            - "22"
            - "5900"
            - "4567"
        networks: 
            - client_net_1
    foo_client_1_2: 
        image: foo_client:latest
        mem_limit: 1g
        memswap_limit: 2g
        links: 
            - foo_server_1:server
        container_name: foo_client_1_2
        ports: 
            - "22"
            - "5900"
            - "4567"
        networks: 
            - client_net_1
    foo_server_2: 
        image: foo_server:latest
        mem_limit: 1g
        memswap_limit: 2g
        container_name: foo_server_2
        ports: 
            - "22"
            - "4567"
        networks: 
            - foo_server_network
            - client_net_2
    foo_client_2_1: 
        image: foo_client:latest
        mem_limit: 1g
        memswap_limit: 2g
        links: 
            - foo_server_2:server
        container_name: foo_client_2_1
        ports: 
            - "22"
            - "5900"
            - "4567"
        networks: 
            - client_net_2
    foo_client_2_2: 
        image: foo_client:latest
        mem_limit: 1g
        memswap_limit: 2g
        links: 
            - foo_server_2:server
        container_name: foo_client_2_2
        ports: 
            - "22"
            - "5900"
            - "4567"
        networks: 
            - client_net_2
networks: 
    foo_server_network: 
    client_net_1: 
    client_net_2: 

Powershell-Output of docker ps-a:

D:\dockerTemp> docker ps -a
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS
PORTS                                                                                                    NAMES
e29f75524e11        foo_client:latest           "/scripts/start.sh"      6 minutes ago       Up 6 minutes
5901/tcp, 6901/tcp, 12345/tcp, 0.0.0.0:33498->22/tcp, 0.0.0.0:33497->4567/tcp, 0.0.0.0:33496->5900/tcp   foo_client_1_1
fb1b4169fff4        foo_client:latest           "/scripts/start.sh"      6 minutes ago       Up 6 minutes
5901/tcp, 6901/tcp, 12345/tcp, 0.0.0.0:33501->22/tcp, 0.0.0.0:33500->4567/tcp, 0.0.0.0:33499->5900/tcp   foo_client_1_2
cb6af51a0ffb        foo_client:latest           "/scripts/start.sh"      6 minutes ago       Up 6 minutes
5901/tcp, 6901/tcp, 12345/tcp, 0.0.0.0:33495->22/tcp, 0.0.0.0:33494->4567/tcp, 0.0.0.0:33493->5900/tcp   foo_client_2_1
6f436f5b3d7c        foo_client:latest           "/scripts/start.sh"      6 minutes ago       Up 6 minutes
5901/tcp, 6901/tcp, 12345/tcp, 0.0.0.0:33492->22/tcp, 0.0.0.0:33491->4567/tcp, 0.0.0.0:33490->5900/tcp   foo_client_2_2
3844553d31a4        foo_server:latest           "/scripts/foo_server"   6 minutes ago       Up 6 minutes
0/tcp, 5901/tcp, 6901/tcp, 12345/tcp, 0.0.0.0:33489->22/tcp, 0.0.0.0:33487->4567/tcp                     foo_server_2
92bcd4273e34        foo_server:latest           "/scripts/foo_server"   6 minutes ago       Up 6 minutes
0/tcp, 5901/tcp, 6901/tcp, 12345/tcp, 0.0.0.0:33488->22/tcp, 0.0.0.0:33486->4567/tcp                     foo_server_1
0 Answers
Related