Connecting to MS SQL Server in container

We've got a Python-based app server running on a Linux image. We're trying to connect to a Linux container running SQL Server on port 1433.

We're using unixODBC and FreeTDS, and everything works when creating a local network (`docker network create --driver bridge --subnet our_network.bridge`), then adding the containers to the network. Then we can access SQL Server's data source by name (`docker run -itd --network=our_network.bridge --name local-mssql microsoft/mssql`), local-mssql in this case.

We can `telnet 1433`, so the port is open. But using unixODBC command line tool isql (parameters: server name, username, password), this is the result:

+ isql -v sqlserver sa supersecret
[ISQL]ERROR: Could not SQLConnect
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Unknown host machine name.

Any idea how we can access to our database?

1 answer

0 vote

Hey @Tim Condit, I'm not super familiar with unixODBC, but I can talk about the general network set up.

When using Pipelines services, the processes running inside these containers all share a network interface with the main step execution container. This is why you can access everything via localhost /, and why there can be no port conflicts between services (can't run nginx and apache on port 80 for example).

As a common rule, each service must listen for connections from localhost/, and the clients should connect to localhost.

Is it possible your command 

isql -v sqlserver sa supersecret 

is trying to connect to a remote host named 'sqlserver' and not `localhost` ?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

29,940 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you