Code in this video_Install Micrsoft SQL Server with Docker on Ubuntu | Debian-based

📌 Replace the highlighted information with your own

✳️ YML

version: '3.8' # Docker Compose file format version

services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest # Use the latest SQL Server 2022 image
container_name: sqlserver2022 # Assign a custom name to the container
ports:
- "1433:1433" # Expose port 1433 for external access (host:container)
environment:
ACCEPT_EULA: "Y" # Accept the End-User License Agreement
SA_PASSWORD: "Your-Password" # Set the password for the 'sa' (system admin) account
volumes:
- sql_data:/var/opt/mssql # Mount a volume to persist SQL Server data
networks:
- mssql-net # Connect this container to the custom network 'mssql-net'

mssql-client:
image: ubuntu # Use a basic Ubuntu image as the SQL client container
container_name: mssql-client # Assign a custom name to the client container
command: tail -f /dev/null # Keep the container running (prevent exit)
networks:
- mssql-net # Connect to the same network to communicate with sqlserver

volumes:
sql_data: # Define a named volume for persistent SQL data

networks:
mssql-net: # Define a custom Docker network for internal communication

✳️ mssql-client

apt install curl gnupg2 apt-transport-https -y

curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

ACCEPT_EULA=Y apt install -y mssql-tools unixodbc-dev

✳️ Add Path

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc

source ~/.bashrc

Leave a Reply

Your email address will not be published. Required fields are marked *