Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error connecting to MS SQL Server 2019 running in a docker container #130

Open
Lancer92 opened this issue Dec 9, 2022 · 2 comments
Open

Comments

@Lancer92
Copy link

Lancer92 commented Dec 9, 2022

I use next docker-compose instructions.

services:
  mssql:
    image: mcr.microsoft.com/mssql/server:2019-latest
    ports:
      - ${DATABASE_PORT}:1433
    volumes:
      - ./.data/db:/var/lib/mssql/data
    environment:
      ACCEPT_EULA: -Y
      MSSQL_SA_USER: ${DATABASE_USERNAME}
      MSSQL_SA_PASSWORD: ${DATABASE_PASSWORD}
  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

However, it works from code (Node.js, TypeORM) but it's shows error when trying to connect from adminer:
SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (localhost) (severity 9)

OS: macOS 12.6
browser: Chrome Version 108.0.5359.98 (Official Build) (x86_64)

NodeJS: 18.12.1

@TimWolla
Copy link
Owner

I'm afraid I won't be able to assist with that, because I don't have any MS SQL experience at all.

@KUT0K1
Copy link

KUT0K1 commented Jan 20, 2023

You need to use the container name instead of localhost. With "container_name:" you can also define this permanently.

Example:

services:
  mssql:
    image: mcr.microsoft.com/mssql/server:2019-latest
    container_name: db-mssql
    ports:
      - ${DATABASE_PORT}:1433
    volumes:
      - ./.data/db:/var/lib/mssql/data
    environment:
      ACCEPT_EULA: -Y
      MSSQL_SA_USER: ${DATABASE_USERNAME}
      MSSQL_SA_PASSWORD: ${DATABASE_PASSWORD}

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants