Hello,
I’m trying to automate a bit of manual setup when starting up my docker containers with docker-compose. I’d like it to create a specific database when it spins up.
services:
mssql:
image: "mcr.microsoft.com/mssql/server:latest-ubuntu"
networks:
- family
environment:
SA_PASSWORD: "123456"
ACCEPT_EULA: "Y"
ports:
- "1433:1433"
python:
build:
context: ./build
dockerfile: python.dock
env_file:
- .env
networks:
- family
volumes:
- .:/home/code
depends_on:
- ubuntu
- mssql
ubuntu:
build:
context: ./build
dockerfile: ubuntu.dock
volumes:
- ./transfer:/home/
networks:
- family
ports:
- "60000:22"
networks:
family:
Currently I have to manually enter the python image and run the command:
sqlcmd -S mssql -U sa -P '123456'
That fires up the sqlcmd prompt where I can then run create database mydatabase
and go
, then exit
to get out of that sqlcmd prompt.
Is there a way to automate this so that it connects and creates the database automatically?