Shahar Hamuzim Rajuan
Shahar Hamuzim Rajuan

Reputation: 6129

Can I connect to remote DB server from inside docker container?

My app is running against a mssql server 2012 or above,

I tried to set up 2 containers - 1 for my app and one to be a DB server.

But I couldn't use the DB container due to mssql server version windows image is not supported by my app.

So I'm want to connect to a remote DB server that I have which is a different server than the Docker host.

How do I get the container to ping the remote DB server?

From the container-

C:\Installation>ping  my0134.company.net
Ping request could not find host my0134.company.net. Please check the name and try again.

** NOTE - I am using Docker on windows

Upvotes: 3

Views: 2073

Answers (2)

Bill Cheng
Bill Cheng

Reputation: 742

Maybe you could try adding <IP of my0134.company.net> my0134.company.net to the etc/hosts file. This way the url can be resolved to a IP address. You can also just use

docker run --add-host 'my0134.company.net':<IP of my0134.company.net> <image>

to spin up your container.

Upvotes: 2

Girdhar Sojitra
Girdhar Sojitra

Reputation: 678

If IPV4 forwarding is enabled then container can connect to DB Server.There is no issue with that.

Upvotes: 0

Related Questions