I am facing an issue here:
version: '2'
services:
ms1:
image: somedtr/someorg/somerepo:v0.1
mem_limit: 512M
environment:
SPRING_PROFILES_ACTIVE: docker-development-cloud
JAVA_OPTS: -Xms256m -Xmx512m
ports:
- "8900:8900"
restart: always
networks:
- docker_dev_cloud
networks:
docker_dev_cloud:
driver: bridge
=======================================
version: '2'
services:
ms2:
image: somedtr/someorg/somerepo:v0.1
mem_limit: 512M
environment:
SPRING_PROFILES_ACTIVE: docker-development-cloud
JAVA_OPTS: -Xms256m -Xmx512m
ports:
- "8900:8900"
restart: always
networks:
- docker_dev_cloud
networks:
docker_dev_cloud:
driver: bridge
i am trying to run the service on docker_dev_cloud but its not running on that network
when i do docker network ls
ms1_docker_dev_cloud
ms2_docker_dev_cloud
Any Help Appreciated, Thanks in Advance
The OP used 2 different .yaml files and 2 different networks were being created maybe because docker-compose uses as project name (by default) the name of the directory with the docker-compose.yaml file. In the comments it was proposed to use:
docker-compose -p project_name up
I have changed your yaml a little bit in order to make something that works and can be demonstrated.
alpine imageentrypoint: ping msX in order to show you that they ping each other.docker-compose.yaml (run it with docker-compose up):
version: '2'
services:
ms1:
image: alpine
mem_limit: 512M
environment:
SPRING_PROFILES_ACTIVE: docker-development-cloud
JAVA_OPTS: -Xms256m -Xmx512m
ports:
- "8900:8900"
restart: always
networks:
- docker_dev_cloud
entrypoint: ping ms2
ms2:
image: alpine
mem_limit: 512M
environment:
SPRING_PROFILES_ACTIVE: docker-development-cloud
JAVA_OPTS: -Xms256m -Xmx512m
ports:
- "8901:8900"
restart: always
networks:
- docker_dev_cloud
entrypoint: ping ms1
networks:
docker_dev_cloud:
driver: bridge
you can see that it works, because ms1 - ms2 actually ping each other.
ubuntu@ubuntu:~/docker_compose_tests/test$ docker-compose up
Creating network "test_docker_dev_cloud" with driver "bridge"
Creating test_ms1_1
Creating test_ms2_1
Attaching to test_ms2_1, test_ms1_1
ms2_1 | PING ms1 (172.22.0.3): 56 data bytes
ms2_1 | 64 bytes from 172.22.0.3: seq=0 ttl=64 time=0.070 ms
ms1_1 | PING ms2 (172.22.0.2): 56 data bytes
ms1_1 | 64 bytes from 172.22.0.2: seq=0 ttl=64 time=0.054 ms
ms2_1 | 64 bytes from 172.22.0.3: seq=1 ttl=64 time=0.286 ms
ms1_1 | 64 bytes from 172.22.0.2: seq=1 ttl=64 time=0.113 ms
ms2_1 | 64 bytes from 172.22.0.3: seq=2 ttl=64 time=0.129 ms
ms1_1 | 64 bytes from 172.22.0.2: seq=2 ttl=64 time=0.086 ms
ms2_1 | 64 bytes from 172.22.0.3: seq=3 ttl=64 time=0.137 ms
ms1_1 | 64 bytes from 172.22.0.2: seq=3 ttl=64 time=0.113 ms
ms2_1 | 64 bytes from 172.22.0.3: seq=4 ttl=64 time=0.246 ms
ms1_1 | 64 bytes from 172.22.0.2: seq=4 ttl=64 time=0.115 ms
ms2_1 | 64 bytes from 172.22.0.3: seq=5 ttl=64 time=0.078 ms
and the network is also created and can be listed:
ubuntu@ubuntu:~/docker_compose_tests/test$ docker network ls
NETWORK ID NAME DRIVER SCOPE
c8562a9231c3 bridge bridge local
412040f6cf69 host host local
1cbabce12616 none null local
59de206c1ffa test_docker_dev_cloud bridge local