compose icon indicating copy to clipboard operation
compose copied to clipboard

Compose services only can connect to each other by IP

Open pradley opened this issue 8 years ago • 3 comments

Here is my Compose File

version: '2.1'

services:
  NotificationProcessor:
    image: notificationprocessor 
    restart: unless-stopped
    depends_on: 
    - SQLServer
    mem_limit: 2G
    environment:
     DataSource: SQLServer
     DBName: IODC_Central
     DBIntegratedSecurity: "false"
     DBUserid: sa
     DBPassword: LoveDocker

  SQLServer:
    image: microsoft/mssql-server-windows-developer
    restart: unless-stopped
    ports:
      - "1433:1433"
    volumes:
      - "C:/Base_4_0_Database/:C:/Base_4_0_Database/"
    environment:
     sa_password: LoveDocker
     ACCEPT_EULA: Y
     attach_dbs: "[{'dbName':'IODC_Central','dbFiles':['C:\\\\Base_4_0_Database\\\\IODC_Central.mdf','C:\\\\Base_4_0_Database\\\\IODC_Central_log.ldf']}]"

Sadly the notification processor can only connect to database if I run the SQL container first then get its IP replace DataSource: SQLServer with
DataSource: 172.26.0.120 (example of a randomly generated ip) inside of the compose file and then compose up the notification processor It should be able to connect to it using the service name so that I could call docker-compose up and it would connect. Anyone have any guidance?

pradley avatar Dec 22 '17 21:12 pradley

I would try using only lowercase characters in your service names. Upper case for host names isn't well supported. Let me know if that helps.

shin- avatar Dec 26 '17 19:12 shin-

Yoo shin you are the man ! You have answered so many of my questions indirectly just by being so involved with so many post and answering other questions (frism also he has helped me alot). Seen you alot around the forums and want to give you a solid thank you for your time and help. Lower casing it did work for me. TY !

pradley avatar Jan 03 '18 20:01 pradley

Glad I could help :blush:

shin- avatar Jan 04 '18 00:01 shin-