Lection 54, Adding Docker Containers, Docker Compose, Volumes

Published: 01 September 2020
on channel: Stoyan Cheresharov
297
7

1. Right mouse click on the Project "D:\projects\dotnet\IdSrv4Quickstart\src\FirstIdSrvAspNetIdentity" - Add - Docker Support

2. Right mouse click on the Project - Add - Orchestration - docker-compose. A new project will be created

3. Change the connection string to use MS SQL from a container
{
"ConnectionStrings": {
"DefaultConnection": "Server=db;Database=master;User=sa;Password=PaSs1234;"
}
}
4. Add to docker-compose.yml
...
depends_on:
db
db:
image: "mcr.microsoft.com/mssql/server"
environment:
SA_PASSWORD: "PaSsword1234"
ACCEPT_EULA: "Y"

5. You can access the containers e.g.: PS docker exec -it idsrv4quickstart_db_1 /bin/bash

6. Use cli to manage MS SQL server:
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "PaSs1234"

SELECT name FROM master.sys.databases
GO

SELECT * FROM INFORMATION_SCHEMA.TABLES;
GO

7. To make MS SQL work with volumes:
Add to
...
db:
volumes:
type: volume
source: firstidsrvaspnetidentitydbsys
target: /var/opt/mssql
type: volume
source: firstidsrvaspnetidentitydbusr
target: /var/opt/sqlserver
...
volumes:
firstidsrvaspnetidentitydbsys:
firstidsrvaspnetidentitydbusr:

References:
Visual Studio Container Tools with ASP.NET Core: https://docs.microsoft.com/en-us/aspn...

Tutorial: Containerize a .NET Core app: https://docs.microsoft.com/en-us/dotn...

Dockerize an ASP.NET Core application: https://docs.docker.com/engine/exampl...

Configure SQL Server container images on Docker: https://docs.microsoft.com/en-us/sql/...

Quickstart: Run SQL Server container images with Docker:    / @stoyancheresharov  

SQL Server 2017 Docker Container And Web API In .Net Core: https://www.c-sharpcorner.com/article...

Quickstart: Compose and ASP.NET Core with SQL Server: https://docs.docker.com/compose/aspne...

Overview of Docker Compose: https://docs.docker.com/compose/

Quickstart: Run SQL Server container images with Docker: https://docs.microsoft.com/en-us/sql/...

Using docker named volumes to persist databases in SQL Server: https://dbafromthecold.com/2019/03/21...


Watch video Lection 54, Adding Docker Containers, Docker Compose, Volumes online without registration, duration hours minute second in high quality. This video was added by user Stoyan Cheresharov 01 September 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 297 once and liked it 7 people.