无法从其他Docker容器访问在一个Docker容器中运行的MS SQL

时间:2017-09-12 12:05:49

标签: ruby-on-rails sql-server docker

我正在运行MS SQL in Docker

我可以从我的工作站访问MS SQL,但如果我尝试从我的rails docker容器连接它就无法运行:

$ docker exec -it 73  bundle exec rails c
Loading development environment (Rails 5.1.3)
[1] pry(main)> User.last
TinyTds::Error: Cannot open server 'mssql' requested by the login.
Client with IP address '109.74.176.74' is not allowed to access the server.  
To enable access, use the Windows Azure Management Portal or run 
sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range.  It may take up to five minutes for this change to take effect.
from /usr/local/bundle/gems/tiny_tds-2.0.0/lib/tiny_tds/client.rb:53:in `connect'

Cannot open server 'mssql' requested by the login. 
Client with IP address '$MY_EXTERNAL_IP' is not allowed to access the server. 
To enable access, use the Windows Azure Management Portal or 
run sp_set_firewall_rule on the master database to 
create a firewall rule for this IP address or address range. 
It may take up to five minutes for this change to take effect.

搬运工-compose.yml

version: '2'

services:
  mssql:
    image: 'microsoft/mssql-server-linux:ctp2-1'
    environment:
      - ACCEPT_EULA=Y
      - SA_PASSWORD=Top-5ecret
      - PATH=$PATH:/opt/mssql-tools/bin:/opt/mssql/bin
    ports:
      - '1433:1433'

  website:
    build: .
    command: bundle exec puma --config config/puma/development.rb

    environment:
      - RACK_ENV=development
      - RAILS_ENV=development      
      - DATABASE_URL=sqlserver://sa:Top-5ecret@mssql:1433/sst-staging

      - AAD_SCOPE=openid
      - AAD_REDIRECT_URI=http://localhost:3000/sst/auth/exchange
      - LOGIN_URI=http://localhost:3000/sst/login

      # Remember to export the following vars to your shell. E.g ~/.profile
      # This will add them to the container if they are present.
      - AAD_TENANT
      - AAD_CLIENT_ID



    ports:
      - '3000:3000'
    volumes:
      - '.:/numbers'
    stdin_open: true
    tty: true

0 个答案:

没有答案