我想在 docker 上本地运行 SQL Server 和 RabbitMQ。但是我不能用我的 sql 脚本初始化 SQL Server 数据库。我的数据库 Dockerfile
FROM microsoft/mssql-server-linux:latest
COPY ./mock-database/db-dump.sql /etc/mock-database/
这是我的 docker-compose.yml
version: '3.1'
services:
rabbitMq:
image: rabbitmq
hostname: localhost
ports:
- "15672:15672"
- "5672:5672"
- "5671:5671"
db:
image: listings_db
ports:
- "1433:1433"
environment:
SA_PASSWORD: "microsoftSucks1!"
ACCEPT_EULA: "Y"
command: /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P microsoftSucks1! -i /etc/mock-database/db-dump.sql
在我用 myscript 运行我的应用程序之后
docker build -t listings_db -f mock-database/databaseDockerfile .
docker build -t rabbitmq -f rabbitmq/rabbitmqDockerfile .
docker-compose -f stack.yml up
我得到了这个例外
db_1 | Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
db_1 | Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2749.
db_1 | Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
如何解决这个问题?