title: Container can't connect to microsoft sql server in docker-compose
body: <p>I have docker-compose.yml file with two services:</p>
  <ul>
  <li>a NodeJs API</li>
  <li>a microsoft mssql database</li>
  </ul>
  <h2>docker-compose.yml:</h2>
  <pre><code>version: &quot;3.7&quot;
  services:
    api:
      container_name: dev_api
      environment:
        - DATABASE_PUBLIC_URL=${DATABASE_URL} # Not used yet
      build: .
      restart: always
      ports:
        - &quot;4100:4100&quot;
      networks:
        - backend
      depends_on:
        - db
  
    db:
      image: mcr.microsoft.com/mssql/server:2017-latest
      restart: always
      ports:
        - &quot;1433:1433&quot;
      environment:
        ACCEPT_EULA: &quot;Y&quot;
        SA_PASSWORD: &quot;Abc123**&quot;
      networks:
        - backend
  
  networks:
    backend:
      driver: bridge
  </code></pre>
  <p>when I run it with <code>docker-compose up</code>, I get :</p>
  <pre><code>...
  021-10-22 14:54:20.77 spid11s     The tail of the log for database model is being rewritten to match the new sector size of 4096 bytes.  2048 bytes at offset 75776 in file /var/opt/mssql/data/modellog.ldf will be written.
  dev_api |   App is running at http://localhost:4100 in development mode
  dev_api |   Press CTRL-C to stop
  dev_api |
  dev_api | ConnectionError: Failed to connect to localhost:1433 - Could not connect (sequence)
  dev_api |     at /usr/src/app/node_modules/mssql/lib/tedious/connection-pool.js:71:17
  dev_api |     at Connection.onConnect (/usr/src/app/node_modules/tedious/lib/connection.js:1043:9)
  dev_api |     at Object.onceWrapper (node:events:510:26)
  dev_api |     at Connection.emit (node:events:390:28)
  dev_api |     at Connection.emit (/usr/src/app/node_modules/tedious/lib/connection.js:1071:18)
  dev_api |     at Connection.socketError (/usr/src/app/node_modules/tedious/lib/connection.js:1669:12)
  dev_api |     at /usr/src/app/node_modules/tedious/lib/connection.js:1428:21
  dev_api |     at SequentialConnectionStrategy.connect (/usr/src/app/node_modules/tedious/lib/connector.js:129:14)
  dev_api |     at Socket.onError (/usr/src/app/node_modules/tedious/lib/connector.js:149:12)
  dev_api |     at Socket.emit (node:events:390:28) {
  dev_api |   code: 'ESOCKET',
  dev_api |   originalError: ConnectionError: Failed to connect to localhost:1433 - Could not 
  dev_api | }
  2021-10-22 14:54:20.80 spid5s      Converting database 'msdb' from version 862 to the current version 869.
  2
  ...
  </code></pre>
  <p>I can access the application from <code>htpp://localhost:4100</code>, but I get error since I can't access the database</p>
  <hr />
  <h1>Edit</h1>
  <p>In the project, there is a file <code>ormconfig.json</code>, the database host needs to be changed.</p>