Wiki do Tiozão do Linux

Instalar SQL-SERVER em Docker

Funciona em arquiteturas x86-64 e arm64

SQL-Server em Docker

Instalação em Ubuntu-Server

Azure SQL Edge components

Azure SQL Edge only supports the database engine. It doesn't include support for other components available with SQL Server 2022 on Windows or with SQL Server 2022 on Linux. Specifically, Azure SQL Edge doesn't support SQL Server components like Analysis Services, Reporting Services, Integration Services, Master Data Services, Machine Learning Services (In-Database), and Machine Learning Server (standalone).

Funciona em arquiteturas: x86-64

# hostnamectl 
 Static hostname: oracle-05
       Icon name: computer-vm
         Chassis: vm
      Machine ID: acf745a802754ce2ba3074df70ef11a4
         Boot ID: 56553bbb80fe45aaa057e94130117853
  Virtualization: kvm
Operating System: Ubuntu 22.04.3 LTS              
          Kernel: Linux 5.15.0-1040-oracle
    Architecture: arm64
 Hardware Vendor: QEMU
  Hardware Model: KVM Virtual Machine

e arm64

# hostnamectl 
 Static hostname: stdlnx001616
       Icon name: computer-desktop
         Chassis: desktop
      Machine ID: b0d275fb46fa48c6820be57edaa22cf5
         Boot ID: d373cf1fd956496d9a4de84060cdba4b
Operating System: Linux Mint 21.2                 
          Kernel: Linux 5.15.0-79-generic
    Architecture: x86-64
 Hardware Vendor: Dell Inc.
  Hardware Model: OptiPlex 3050

Azure SQL Edge - By Microsoft - Official container images for Microsoft Azure SQL Edge for docker engine

mkdir -p /root/docker/sql-server
cd /root/docker/sql-server

cat docker-compose.yml

services:
  sql-edge:
    image: 'mcr.microsoft.com/azure-sql-edge'
    container_name: sqledge                   # Nome do container
    restart: unless-stopped
    ports:
      - '1433:1433'                           # Default Port
    environment:
      - ACCEPT_EULA=1                         # Confirmar sua aceitação dos Termos de Licença
      - MSSQL_SA_PASSWORD=Mystr0ngP@ssw0rd    # No mínimo 8 characters e conter: Maiúsculas, Minúsculas, Digitos e Simbolos
      - MSSQL_TELEMETRY_ENABLED=FALSE         # Não enviar dados de telemetry para Microsoft
    volumes:
      - ./data:/data/                         # Local para dump futuro (ainda em testes)
      - sqlvolume:/var/opt/mssql
volumes:
  sqlvolume:

Importante: A variável de ambiente MSSQL_PID do SQL no Edge só aceita Premium e Developer como valores válidos. O SQL do Azure no Edge não é compatível com inicialização usando uma chave do produto.

docker compose up -d
[+] Running 2/2
 ✔ Network sql-server_default  Created
 ✔ Container sqledge           Started

docker compose ps
NAME                IMAGE                              COMMAND                  SERVICE             CREATED             STATUS              PORTS
sqledge             mcr.microsoft.com/azure-sql-edge   "/opt/mssql/bin/perm…"   sql-edge            50 seconds ago      Up 50 seconds       1401/tcp, 0.0.0.0:1433->1433/tcp, :::1433->1433/tcp

docker compose logs -f

sqledge  | Azure SQL Edge will run as non-root by default.
sqledge  | This container is running as user mssql.
sqledge  | To learn more visit https://go.microsoft.com/fwlink/?linkid=2140520.
sqledge  | 2023/08/29 16:13:17 [launchpadd] INFO: Extensibility Log Header: <timestamp> <process> <sandboxId> <sessionId> <message>
sqledge  | 2023/08/29 16:13:17 [launchpadd] WARNING: Failed to load /var/opt/mssql/mssql.conf ini file with error open /var/opt/mssql/mssql.conf: no such file or directory
sqledge  | 2023/08/29 16:13:17 [launchpadd] ERROR: RevoScaleR installation was not found. RevoScaleR is required to be installed in order to use R scripts.
sqledge  | 2023/08/29 16:13:17 [launchpadd] ERROR: revoscalepy installation was not found. revoscalepy is required to be installed in order to use Python scripts.
sqledge  | 2023/08/29 16:13:17 [launchpadd] INFO: DataDirectories =  /bin:/etc:/lib:/lib32:/lib64:/sbin:/usr/bin:/usr/include:/usr/lib:/usr/lib32:/usr/lib64:/usr/libexec/gcc:/usr/sbin:/usr/share:/var/lib:/opt/microsoft:/opt/mssql-extensibility:/opt/mssql/mlservices:/opt/mssql/lib/zulu-jre-11:/opt/mssql-tools
sqledge  | 2023/08/29 16:13:17 Drop permitted effective capabilities.
sqledge  | 2023/08/29 16:13:18 [launchpadd] INFO: Polybase remote hadoop bridge disabled
sqledge  | 2023/08/29 16:13:18 [launchpadd] INFO: Launchpadd is connecting to mssql on localhost:1431
sqledge  | 2023/08/29 16:13:18 [launchpadd] WARNING: Failed to connect to SQL because: dial tcp 127.0.0.1:1431: getsockopt: connection refused, will reattempt connection.
.....
2023-08-29 16:22:55.61 Logon       Error: 18456, Severity: 14, State: 8.
2023-08-29 16:22:55.61 Logon       Login failed for user 'sa'. Reason: Password did not match that for the login provided. [CLIENT: 10.10.2.2]

Acessando o container

sqlcmd tool is not available inside the ARM64 version of SQL Edge containers.

# docker exec -it sqledge /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Mystr0ngP@ssw0rd
1> quit

Dump do BD de forma remota

cd
wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5_amd64.deb
sudo dpkg -i libssl1.0.0_1.0.2n-1ubuntu5_amd64.deb
sudo apt install python-is-python3

sudo pip install mssql-scripter

mssql-scripter -S localhost -d teste -U sa -P Mystr0ngP@ssw0rd --schema-and-data  > ./teste.sql

ls -lh teste.sql
-rw-r--r-- 1 jjunior domain users 13M ago 29 13:43 teste.sql

Referências

  1. https://hub.docker.com/_/microsoft-azure-sql-edge
  2. https://learn.microsoft.com/en-us/azure/azure-sql-edge/disconnected-deployment
  3. https://learn.microsoft.com/pt-br/azure/azure-sql-edge/configure#configure-by-using-environment-variables
  4. https://learn.microsoft.com/pt-br/sql/linux/sql-server-linux-configure-environment-variables?view=sql-server-ver16
  5. Run SQL Server Linux container - https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-ver17&tabs=cli&pivots=cs1-bash
  6. Microsoft Artifact Registry - https://mcr.microsoft.com/artifact/mar/mssql/server/about
  7. https://github.com/twright-msft/mssql-node-docker-demo-app
  8. https://database.guide/how-to-install-sql-server-on-an-m1-mac-arm64/
  9. https://docker-unleashed.readthedocs.io/aula2.html
  10. https://www.cloudfronts.com/uncategorized/making-sql-server-accessible-over-internet/
  11. https://dba.stackexchange.com/questions/212856/command-line-tool-script-to-backup-a-remote-sql-server-database-to-local-disk
  12. https://renatogroffe.medium.com/sql-server-docker-compose-criando-rapidamente-ambientes-e-populando-bases-para-testes-13d108d8cdb2
  13. https://vijayasimhabr.medium.com/running-microsoft-sql-database-server-with-docker-5a879ef06adb
  14. https://dev.to/danilosilva/sql-server-docker-compose-como-criar-e-popular-bancos-de-dados-ao-inicializar-os-containers-4ilf