Amine Mostefai's Blog

Architecture is my passion :)

Amine

Hi and welcome to my blog. I share in this space a lot of posts related to software architecture, and software development. Content is mainly related to .NET CORE development, Angular, Sharepoint, Azure and Office 365. I hope that my articles are helpful and that you enjoy using them 😉

Backing up a database from a SQL Server 2019 container

Hi all,

If you have pulled the latest version of the Linux-based SQL Server 2019 containers, you will notice that you cannot backup databases anymore in the container file system. That's because the cause is pretty obvious, the mssql user has no longer the required permissions to create files.

One of the quickest workarounds is to execute the container using the root user. For example, the command below, runs a container using the root user.

docker run -u root mcr.microsoft.com/mssql/server

If you are using the container inside a compose, just modifiy the configuration by adding "root" for the "user" parameter as follows :

services: 
  sqldb:
    image: 'mcr.microsoft.com/mssql/server:2019-latest'
    user: root
    environment:
        SA_PASSWORD: "Vibr@tion99"
        ACCEPT_EULA: "Y"
    ports:
        - 1433:1433
    volumes:
        - sqlvolume:/var/opt/mssql
        - c:/temp/backup:/var/backup

Hope that was helpful !

Loading