
To get started with Azure SQL Edge Docker, you'll need to create a container using the Azure SQL Edge image. This can be done using the Docker CLI or a tool like Docker Desktop.
Azure SQL Edge Docker is a compact, edge-based SQL database that can be deployed on IoT devices, gateways, or other edge computing devices. It's designed to provide a secure and scalable way to store and manage data in remote locations.
To create a container, you'll need to pull the Azure SQL Edge image from Docker Hub. The image is available under the Microsoft/mssql-server-azure-sql-edge repository.
You can then use the Docker CLI to run the container, specifying the desired configuration options. For example, you can use the -e option to set environment variables, such as the database name and password.
Additional reading: Azure Cli vs Azure Powershell
Prerequisites
To get started with Azure SQL Edge Docker, you'll need to meet some basic requirements. Docker Engine 1.8+ must be installed on any supported Linux distribution, and Ubuntu 18.04 is recommended.
You'll also need a Docker overlay2 storage driver, which is the default for most users. If you're not using this storage provider, you'll need to configure it according to the Docker documentation.
To ensure smooth performance, you'll need a minimum of 10 GB of disk space. This will give you enough room to store the SQL Edge images and other necessary files.
In addition to disk space, you'll also need a minimum of 1 GB of RAM. This will allow you to run the SQL Edge container without any issues.
Here are the specific requirements in a concise list:
- Docker Engine 1.8+
- Docker overlay2 storage driver
- Minimum of 10 GB of disk space
- Minimum of 1 GB of RAM
Container Management
Container management is crucial to ensure your Azure SQL Edge Docker container is running smoothly. You can pull and run the container image using the command `sudo docker pull mcr.microsoft.com/azure-sql-edge:latest`.
To run the container, you'll need to use the following command in the bash shell: `docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong(!)Password" -p 1433:1433 --name azuresqledge -d mcr.microsoft.com/azure-sql-edge:latest`. This command sets the ACCEPT_EULA variable, specifies a strong password for the SA account, maps port 1433, and runs the container in detached mode.
The container can be viewed using the `docker ps` command, which will display the container's status and port. If the status is "Up", it means the SQL Edge is running and listening on the specified port.
Recommended read: Pull and Run Docker Image from Azure Container Registry
拉取并运行容器映像
To pull and run the Azure SQL Edge container image, start by pulling the image from Azure Container Registry. You can do this by running the command `sudo docker pull mcr.microsoft.com/azure-sql-edge:latest`.
The latest image will be pulled, and you can view all available images on the Azure SQL Edge Docker Hub page.
To run the container image, use the command `docker run` in a bash shell. The command should include parameters to set the SQL Edge settings, such as the `ACCEPT_EULA` variable and a strong password for the `MSSQL_SA_PASSWORD` variable.
Here's a breakdown of the parameters:
If you want to view all Docker containers, use the command `sudo docker ps -a`.
Outside the Container
You can connect to a SQL Edge instance on your Docker machine from any external tool that supports SQL connections, such as Linux, Windows, or macOS.
This means you can access your SQL Edge instance from outside the container, which is super convenient.
You can use any Linux, Windows, or macOS tool to connect to your SQL Edge instance, as long as it supports SQL connections.
For more detailed information on connecting to a SQL Edge container from outside, check out the official documentation on Connect and Query Azure SQL Edge.
Intriguing read: What Is Windows Azure Sql Database
删除容器

Deleting a container is a permanent action that will erase all data within it.
To stop and delete the SQL Edge container used in this tutorial, run the following command.
Warning: Stopping and deleting the container will permanently delete all data within it. If you need to preserve data, create and copy backup files outside the container or use container data retention techniques.
Intriguing read: Azure Data Studio Connect to Azure Sql
Container on Same Host
Connecting to Azure SQL Edge from another container on the same host is a breeze.
Because two containers running on the same host are on the same Docker network, you can easily access them by using the container name and the port address for the service.
You can use a connection string similar to the one mentioned in the example, which assumes Azure SQL Edge is configured to listen on the default port.
This makes it easy to connect to Azure SQL Edge from another Python module (container) on the same host, using the container name and port address.
Azure SQL Edge Tools
You can connect to an instance of Azure SQL Edge from various tools.
sqlcmd is already included in the container image of Azure SQL Edge, allowing you to run it locally if you attach to a running container with an interactive bash shell.
SQL Server Management Studio, Azure Data Studio, and Visual Studio Code are also supported tools for connecting to Azure SQL Edge.
To connect to an Azure SQL Edge Database Engine from a network machine, you'll need the IP address or network name of the host machine, the Azure SQL Edge container host port mapping, and the SA password for the Azure SQL Edge instance.
Here are the details you'll need for the host machine and container port mapping:
The SA password for the Azure SQL Edge instance is the value specified for the MSSQL_SA_PASSWORD environment variable during deployment of Azure SQL Edge.
Container Networking
Connecting to Azure SQL Edge from different containers and machines is a breeze, thanks to Docker networking.
You can easily access another container on the same host by using the container name and port address for the service, making it a great option for connecting to Azure SQL Edge from another Python module on the same host.
If you're trying to connect to Azure SQL Edge from another machine on the network, you'll need to use the IP address of the Docker host and the host port to which the Azure SQL Edge container is mapped.
For example, if the IP address of the Docker host is 192.168.2.121, and the Azure SQL Edge container is mapped to host port 1600, then the server address for the instance of Azure SQL Edge would be 192.168.2.121,1600.
Frequently Asked Questions
Is Azure SQL Edge the same as SQL Server?
Azure SQL Edge shares the same database engine as SQL Server, but it's designed for edge computing and IoT devices. This similarity in engine means you can leverage the same T-SQL programming skills and enjoy seamless portability between environments.
How to connect to an Azure SQL database from Docker Container?
To connect to an Azure SQL database from a Docker container, use the 'docker exec' command to access the container's bash shell and then connect locally with sqlcmd. This process allows you to interact with your Azure SQL database from within the container.
What is the default user in Azure SQL Edge Docker?
The default user in Azure SQL Edge Docker is "mssql", a non-root user. Learn more about running Azure SQL Edge as a non-root user and persisting data securely.
Sources
- https://learn.microsoft.com/en-us/azure/azure-sql-edge/disconnected-deployment
- https://www.linkedin.com/pulse/comprehensive-guide-using-azure-sql-edge-docker-macos-anilkumar-reddy-6w77c
- https://victoryoalli.me/using-docker
- https://docs.azure.cn/zh-cn//azure-sql-edge/disconnected-deployment
- https://learn.microsoft.com/en-us/azure/azure-sql-edge/connect
Featured Images: pexels.com