Build SQL Server Container Using Docker Compose file

As DBA, DevOps, and Data Engineer we should look for the most optimal way to maintain our environments however Docker Compose would be our best answer In a SQL Server Container world.

What is Docker Compose?
Docker Compose is a tool for defining and running multi-container Docker application and/or database services using a single YAML/YML file. With a single command, you create, start, and stop all the services from your configuration.

The features of Docker Compose that make it effective are:

Let’ us demo it. Copy below script, and save it as docker-compose.yml file.

version: '3.3'

        container_name: db-server-demo
          - "1411:1433"
          - "5022:5022"
          SA_PASSWORD: "Password0!"
          ACCEPT_EULA: "Y"
          MSSQL_AGENT_ENABLED: "true"
          MSSQL_MEMORY_LIMIT_MB: 4096
          MSSQL_COLLATION: "Latin1_General_CI_AI"
          MSSQL_DATA_DIR: "/var/opt/mssql/data"
          MSSQL_LOG_DIR: "/var/opt/mssql/dblogs"
          MSSQL_BACKUP_DIR: "/var/opt/mssql/backups"
          MSSQL_DUMP_DIR: "/var/opt/mssql/sqldumps"
          - C:\mssql\data:/var/opt/mssql/data
          - C:\mssql\dblog:/var/opt/mssql/dblogs
          - C:\mssql\Backup:/var/opt/mssql/backups
          - C:\mssql\sqldumps:/var/opt/mssql/sqldumps
          - C:\mssql\logfile:/var/opt/mssql/log          
          - C:\mssql\secrets:/var/opt/mssql/secrets

Please navigate under the directory where docker compose file is located then run docker-composeĀ config script to validate docker-compose.yml file. If no error messages returned, then go ahead and execute below script to deploy SQL Server container using docker-compose.yml file.

docker-compose up -d

Docker Compose file is the recommended way for managing the whole life-cycle of your application or environments. Within a single file and command you are able to:

  • Start, stop, and rebuild services
  • View the status of running services
  • Stream the log output of running services
  • Run a one-off command on a service

Published by Jean Joseph

Jean Joseph is a Database, Big Data, Data Warehouse Platform, Data Pipeline, Database Architecture Solutions Provider as well as a Data Engineer enthusiast among other disciplines.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: