Setting Up SQL Server on Mac with Docker

Sep 30, 2024

Running SQL Server on M1/M2 Mac Using Docker

Introduction

  • Objective: Guide on running SQL Server on M1/M2 Mac using Docker.
  • Context: Previous video on Windows setup led to Mac users facing issues. Transitioned to using a MacBook for demonstration.

Challenges of Running SQL Server on Mac

  • SQL Server lacks a Docker image for ARM processors (used in M1/M2 Macs).
  • Solution: Use Azure SQL Edge, which supports ARM processors.
    • Primarily for IoT; sufficient for development with some feature limitations.

Setting Up Azure SQL Edge

  • Step 1: Pull the Azure SQL Edge Docker image.
    • Use command from Azure SQL Edge Docker page.
  • Step 2: Start the container.
    • Use the provided docker run command.
    • Important: Change the password to a strong one (capital letters, numbers, symbols).

Understanding the Docker Run Command

  • Command: docker run with options:
    • --cap-add=SYSPTRACE: Adds Linux capabilities (traces processes).
    • -e ACCEPT_EULA=1: Accepts the End User License Agreement.
    • -e SA_PASSWORD=[your password]: Sets the sysadmin password.
    • -p 1443:1433: Maps port 1443 on host to 1433 in container.
    • --name azure-sql-edge: Names the container.
    • -d: Runs the container in detached mode (background).
    • Image Name: Matches the pulled image.

Connecting to Azure SQL Edge

  • Use Azure Data Studio.
  • Connection settings: Server localhost, Username sa, Password (used in previous step).
  • Verify by checking default databases.

Persistent Data Storage

  • Without persistence, container shutdown/deletion leads to data loss.
  • Solution: Use data volume containers (not host directories on Mac).
    • Create a Docker volume (e.g., SQL volume) and map it inside the container.
    • Use the same volume name for persistence across container restarts.

Managing Docker Volumes

  • View Volumes:
    • Docker Desktop: Left panel under volumes.
    • Command Line: docker volume list.
  • Deleting Volumes:
    • Delete unused or unwanted volumes via Docker Desktop or docker volume rm [volume_name].

Troubleshooting Docker Containers

  • Viewing Logs:
    • Docker Desktop: Click on the container to view logs.
    • Command Line: Use docker logs [container_id].
    • For real-time log updates, use docker logs -f [container_id].
  • Common Errors: Strong password requirement failures.
    • Ensure the password meets SQL Server policy standards.

Conclusion

  • Provides a method to run SQL Server-like capabilities on Mac using Docker.
  • Highlights persistence solutions and troubleshooting tips.
  • Encourages feedback and interactions via comments.