Umbraco setup in Linux with Containerized SQL server

Muhammad UsamaMuhammad Usama
2 min read

Setting up Umbraco on a Linux system with a containerized SQL Server can streamline your development process and ensure a robust, scalable environment.

This guide will walk you through the steps to install the .NET SDK, set up Umbraco, and create a SQL Server container using Docker. By the end, you'll have a fully functional Umbraco instance connected to a SQL Server database, ready for your web development projects.

Install .NET SDK

sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-8.0

Verify the installation

Install the Umbraco templates

dotnet new install Umbraco.Templates

dotnet new umbraco --name MyUmbraco

update Application URL

sed -i 's/localhost/0.0.0.0/g' MyUmbraco/Properties/launchSettings.json

that's it now for Umbraco, We will be moving towards creating an SQL server container.

Create a SQL server container

we are using the Microsft mcr.microsoft.com/mssql/server:2022-latest image from docker hub. Follow these steps to create the container

sudo docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong@Password123!" \
   -p 1433:1433 --name sql1 --hostname sql1 \
   -v sqlvolume:/var/opt/mssql \
   -d \
   mcr.microsoft.com/mssql/server:2022-latest

for creating the initial DB we will be using Azure data GUI, you can also use CLI if you preferred, we discussed earlier in our blog how we can create a DB using CLI

you can install it from here

https://learn.microsoft.com/en-us/azure-data-studio/download-azure-data-studio

click on Database --> new Query

create a DB

USE master;
GO

CREATE DATABASE  umbracoDB;
GO

Now we will use this DB for our Umbraco Project, now go to the browser tab to Umbraco,

Connecting Ubmraco with SQL server container

Now we have an SQL server container running, we will use this SQL server with Umbraco.

Run the Application

cd MyUmbraco
dotnet watch run

Access the application in SSL Port,

I am accessing my server IP with port 44367

and provide the DB name you created from Azure Studio or CLI earlier,

it will redirect to the login page login with the email and password you set above

you can also verify that it has created the tables in the

SQL server

what if our SQL server container restart

let's verify

we can still log in and our data in the SQL server persists,

what if we remove the container, and start again with the same command, data will also persist, because we utilized docker volumes

sudo docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong@Password123!" \
   -p 1433:1433 --name sql1 --hostname sql1 \
   -v sqlvolume:/var/opt/mssql \
   -d \
   mcr.microsoft.com/mssql/server:2022-latest
0
Subscribe to my newsletter

Read articles from Muhammad Usama directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Muhammad Usama
Muhammad Usama

I am a DevOps Engineer passionate about cloud computing.