I am using Docker + Rails + Tiny TDS on Windows. This configuration worked great until I started dockerizing the environment. Any help is much appreciated.
Gemfile
gem 'tiny_tds'
gem 'rails', '4.2.8'
DockerFile
FROM ruby:2.4.0
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN apt-get update && apt-get install -y dos2unix
RUN apt-get update && apt-get install -yq freetds-bin
RUN mkdir /myapp
WORKDIR /myapp
ADD Gemfile /myapp/Gemfile
ADD Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
COPY . /myapp
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
# Start the main process.
RUN dos2unix entrypoint.sh && apt-get --purge remove -y dos2unix && rm -rf /var/lib/apt/lists/*
EXPOSE 3000
Docker-compose.yml
version: '3'
services:
db:
image: postgres:12-alpine
redis:
image: redis:alpine
server:
tty: true
stdin_open: true
build: .
command: bash -c "rm -f tmp/pids/server.pid && rake db:create && rake db:migrate && bundle exec rails s -p 3000 -b '0.0.0.0'"
links:
- db
- redis
volumes:
# - ./tmp/db:/var/lib/postgresql/data
- .:/usr/src/app
# - .:/myapp
ports:
- "3000:3000"
- "1433:1433"
- "1434:1434"
environment:
DATABASE_URL: postgres://postgres@db:5432/app?pool=25&encoding=unicode&schema_search_path=public
# DEVISE_JWT_SECRET_KEY: RANDOM_SECRET
REDIS_URL: redis://redis:6379
When I test the connection
client = TinyTds::Client.new username: 'sa',
password: 'password',
port: 1433,
host: 'server_name', # works if you are not using docker
# dataserver: 'server_name', #This did not work as well
timeout: 10000
Error message:
TinyTds::Error: Server name not found in configuration files from /usr/local/bundle/gems/tiny_tds-1.0.4/lib/tiny_tds/client.rb:43:in `connect'
Any help is much appreciated.
As per @lyzard-kyng comment on the question the IP address helped diagnose the issue. The DNS suffix properties were managed by windows. I had to add them to the server_name.