【问题标题】:TinyTds::Error: Server name not found in configuration filesTinyTds::Error: 在配置文件中找不到服务器名称
【发布时间】:2019-10-29 18:50:59
【问题描述】:

我在 Windows 上使用 Docker + Rails + Tiny TDS。 在我开始对环境进行 docker 化之前,此配置非常有效。 任何帮助深表感谢。

宝石文件

gem 'tiny_tds'
gem 'rails', '4.2.8'

Docker 文件

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

当我测试连接时

    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

错误信息:

TinyTds::Error: 在配置文件中找不到服务器名称 /usr/local/bundle/gems/tiny_tds-1.0.4/lib/tiny_tds/client.rb:43:in `连接'

非常感谢任何帮助。

【问题讨论】:

  • 尝试用它的IP地址替换server_name。如果这可行,则说明容器内的名称解析(DNS 解析器)存在一些问题。
  • 我已经尝试了IP地址,但没有帮助。
  • @lyzard-kyng,在Rails控制台进一步测试后,服务器名称必须有服务器的完整后缀。

标签: ruby-on-rails docker tiny-tds


【解决方案1】:

根据@lyzard-kyng 对该问题的评论,IP 地址有助于诊断问题。 DNS 后缀属性由 windows 管理。我必须将它们添加到 server_name。

【讨论】:

    猜你喜欢
    • 2016-12-09
    • 2012-10-03
    • 2018-01-25
    • 2018-01-17
    • 1970-01-01
    • 2018-01-02
    • 2016-06-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多