You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example of SQL Server Replication in containers. This demo uses docker-compose to start two SQL Server containers; one that acts as the publisher and distributor, and the other as the subscriber in a push snapshot configuration.
This demo uses docker-compose to start two SQL Server containers; one that acts as the publisher and distributor, and the other as the subscriber in a push snapshot configuration.
4
+
5
+
6
+
### How to Use
7
+
8
+
1. Run the following command in this directory:
9
+
10
+
```
11
+
docker-compose up
12
+
```
13
+
note: this will take approx. 2 min.
14
+
15
+
In your terminal, you should see something like this
16
+
```
17
+
db1 | Job 'DB1-Sales-SnapshotRepl-1' started successfully.
18
+
db1 | Creating Snapshot...
19
+
db1 | Job 'db1-Sales-SnapshotRepl-DB2-1' started successfully.
20
+
```
21
+
22
+
2. Connect to the subscriber listening on localhost,2600 and see that the Sales Database has a Customer table with data in it.
23
+
note: credentials are listed in the **docker-compose.yml**
24
+
25
+
3. when you are done, clean up by running the following command
26
+
```
27
+
docker-compose down
28
+
```
29
+
30
+
31
+
32
+
### How it Works
33
+
34
+
1. Both SQL Server containers start with the environment variables specified in the docker-compose file. In this example, **db1** is the publisher/distributor and **db2** is the subscriber.
35
+
2.*db1/db-init.sh* and *db2/db-init.sh* waits for SQL Server to start up and run the *db-init.sql* scripts
36
+
3.*db1/db-init.sql* creates a *Sales* Database with *Customer* table and sample data, and proceeds by setting up snapshot replication.
37
+
4.*db2/db-init.sql* creates a *Sales* Database.
38
+
5. db1 starts replication jobs to push the snapshot to db2
#start SQL Server, start the script to create/setup the DB
2
+
#You need a non-terminating process to keep the container alive.
3
+
#In a series of commands separated by single ampersands the commands to the left of the right-most ampersand are run in the background.
4
+
#So - if you are executing a series of commands simultaneously using single ampersands, the command at the right-most position needs to be non-terminating
0 commit comments