-
Notifications
You must be signed in to change notification settings - Fork 1
/
intro-demos.ps1
66 lines (56 loc) · 2.11 KB
/
intro-demos.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
New-Alias azuredatastudio "C:\Program Files\Azure Data Studio\azuredatastudio.exe"
### Hello World!
docker pull hello-world
docker run -it --rm --name hello hello-world
# cleanup
docker image rm hello-world
### custom image
cd /src/github.com/giuliov/db-testing/src/custom-image
code . # describe the Dockerfile and shell script
docker images ls
docker build . --tag custom:v1
docker images ls
docker run -it --rm --name bash0 custom:v1
docker ps
# cleanup
docker image rm bash:4.4 custom:v1
### SQL Server
docker pull mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
$SA_PASSWORD = Read-Host -Prompt "SQL Server SA password"
docker run --name sql0 --rm -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$SA_PASSWORD" -p 1433:1433 mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
# see the messages and wait about 30 seconds
azuredatastudio
# connect to localhost
# new query
SELECT @@VERSION
CREATE DATABASE test
# refresh locahost panel
### see what happens after we stop the container
docker stop sql0
docker ps
docker run --name sql0 -d --rm -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$SA_PASSWORD" -p 1433:1433 mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
docker ps
# switch to azuredatastudio
# connect to localhost
# database is GONE!
### Volumes
#Create a volume, mount and create the database on the volume.
docker volume create sqldata
docker run -v sqldata:/var/opt/mssql --name sql1 -d --rm -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$SA_PASSWORD" -p 1433:1433 mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
# switch to azuredatastudio
# connect to localhost
# CREATE DATABASE test
#Now, stop the container and show that the database survived.
docker stop sql1
docker ps
# now we see if the database survived
docker run -v sqldata:/var/opt/mssql --name sql1 -d --rm -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$SA_PASSWORD" -p 1433:1433 mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
# switch to azuredatastudio
# connect to localhost
# shows that it is possible to have more than one process in a Container
docker exec -u 0 -it sql1 /bin/bash -c "ls -l /var/opt/mssql/data"
#Clean up
docker stop sql1
docker ps
docker volume rm sqldata
docker volume ls