I try to create a docker container of mssql database that is filled up with data when I start it.
I would like to start the database by using the command 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
And after i ran the above mentioned command i get
/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
The return code says, that the command sqlcmd
was not found in the PATH of your container. In the documentation https://hub.docker.com/_/microsoft-mssql-server you can see that sqlcmd
is in /opt/mssql-tools/bin/
so modify your RUN command to use the full path.