Connect local SQL server using docker

I'm trying to get data from local server using a mssql node hosted in a docker container in the same pc. But it throws me this error.

getaddrinfo ENOTFOUND <ServerName>

I have checked the firewall and tcp ports. They seems fine.

Docker is a virtual environment. So unless you've allowed the port number for the sql server to be used by the node-red Docker instance, you won't be able to access it.

Hi @TotallyInformation So can I use the same port (1433) for the docker.

1 Like

My advice when it comes to docker - don't use it unless you really need to. And when you get stuck, head to the docker forums or stack overflow because you won't be the first (or last) to have issue setting up.

Personally, for node-red, I see little benefit of using docker. Just my 2¢, ymmv

1 Like

Hi @Steve-Mcl Thanks for the advice

Docker is awesome. Less ressources, scalable, ready in seconds. Updating the container is a snap.
But i admit, you have to know how to configure and administer your container.
Take the following docker-compose.yml file and start it with "docker-compose up [-d]", release it later on with "docker-compose down"
Voila, Nodered is ready to serve on host port 2880. MSSQL-DB is only accessible for the Nodered container on Port 1433, otherwise add additonal container to the compose file or make it accessible on the host. Data (flows etc.) for nodered goes to ./volumes/nodered and for mssqldb to ./volumes/mssqldb

version: "3.7"

services:
node-red:
image: nodered/node-red:latest
container_name: nodered_con
environment:
- TZ=Europe/London
ports:
- "2880:1880" # port 2880 to access on host
- ./volumes/node-red:/data
restart: unless-stopped

mssqldb:
image: Microsoft Artifact Registry
container_name: mssqldb_con
environment:
SA_PASSWORD: "Your Secret PASS"
TZ: "Europe/London"
ACCEPT_EULA: "Y"
expose:
- 1433
volumes:
- ./volumes/mssqldb:/var/opt/mssql
restart: unless-stopped

You should lint your .yml file with "docker-compose config" beforehand.

Hi @davall is that yamal createing a seperate MSSQL container.

mssqldb:
image: [mcr.microsoft.com/mssql/server](http://mcr.microsoft.com/mssql/server)
container_name: mssqldb_con
environment:
SA_PASSWORD: "***Your Secret PASS*** "
TZ: "Europe/London"
ACCEPT_EULA: "Y"
expose:
- 1433
volumes:
- ./volumes/mssqldb:/var/opt/mssql
restart: unless-stopped

Yes, one container for nodered and one for the database.
If you have another DB on your host on port 1433, the containerized database doesn't affect your host database.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.