gpt4 book ai didi

sql-server - 为什么在docker-compose up构建期间找不到sqlcmd?

转载 作者:行者123 更新时间:2023-12-02 20:42:10 25 4
gpt4 key购买 nike

我尝试创建一个mssql数据库的docker容器,该容器在启动时会充满数据。

我想通过使用命令docker-compose up --build启动数据库

docker.yml
version: '3.7'

networks:
sqlserver:
ipam:
config:
- subnet: 172.20.0.0/24

services:

mssql:
container_name: "mssql"
build:
context: ./
dockerfile: Dockerfile

networks:
sqlserver:
ipv4_address: 172.20.0.5

environment:
SA_PASSWORD: "VerySecretP4ssword!"
ACCEPT_EULA: "Y"

ports:
- "1433:1433"

FROM mcr.microsoft.com/mssql/server:latest
RUN mkdir -p /var/opt/mssql/backup

COPY backup.bak /var/opt/mssql/backup
COPY restoreScript.sql /var/opt/mssql/backup

RUN sqlcmd -i /var/opt/mssql/backup/restoreScript.sql


在运行上述命令后,我得到
/bin/sh: 1: sqlcmd: not found
ERROR: Service 'mssql' failed to build: The command '/bin/sh -c sqlcmd -i /var/opt/mssql/backup/restoreScript.sql' returned a non-zero code: 127

最佳答案

返回代码表明,在容器的PATH中找不到命令sqlcmd。在文档https://hub.docker.com/_/microsoft-mssql-server中,您可以看到sqlcmd/opt/mssql-tools/bin/中,因此请修改RUN命令以使用完整路径。

关于sql-server - 为什么在docker-compose up构建期间找不到sqlcmd?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61872171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com