The Mock Register image is available on Docker Hub.
There are a number of ways that this image can be used.
Run the following command to pull the latest image from Docker Hub:
docker pull consumerdataright/mock-register
You can also pull a specific image by supplying a tag, such as the name of the branch ("main" or "develop") or a release number:
# Pull the image from the main branch
docker pull consumerdataright/mock-register:main
# Pull the 0.5.0 version of the image
docker pull consumerdataright/mock-register:0.5.0
The Mock Register relies on SQL Server for data persistence so the container has a dependency on the SQL Server container image provided by Microsoft.
In order to run the Mock Register and related SQL Server instance, use the provided docker-compose.yml
file.
# Navigate to the Source directory where the docker-compose.yml file is located.
cd .\Source
# Run the Mock Register and SQL Server containers.
docker-compose up -d
# When finished, stop the containers.
docker-compose down
The docker-compose.yml
file utilises the Microsoft SQL Server Image from Docker Hub. The Microsoft EULA for the Microsoft SQL Server Image must be accepted to continue.
Set the ACCEPT_EULA
environment variable to Y
within the docker-compose.yml
if you accept the EULA.
See the Microsoft SQL Server Image on Docker Hub for more information.
Example of accepting the ACCEPT_EULA
environment variable of the SQL Server container.
mssql:
container_name: sql1
image: 'mcr.microsoft.com/mssql/server:2019-latest'
ports:
- '1433:1433'
environment:
- ACCEPT_EULA=Y
By default, the Mock Register will run using a host name of mock-register
.
When running locally, to resolve the mock-register
host name, an entry can be added to the hosts
file of the local machine.
127.0.0.1 mock-register
Multiple containers can be run concurrently to simulate a CDR ecosystem. The Mock Register, Mock Data Holder, Mock Data Holder Energy and Mock Data Recipient containers can be run by using the docker-compose.Ecosystem.yml
file.
# Navigate to the Source directory where the docker-compose.Ecosystem.yml file is located.
cd .\Source
# Run the Mock and SQL Server containers.
docker-compose -f docker-compose.Ecosystem.yml up -d
# When finished, stop the containers.
docker-compose -f docker-compose.Ecosystem.yml down
Like the docker-compose.yml
file, the docker-compose.Ecosystem.yml
file also requires acceptance of the EULA for the SQL Server image.
Each Mock solution has a default host name, as per below:
Mock solution | Default host name |
---|---|
Mock Register | mock-register |
Mock Data Holder | mock-data-holder |
Mock Data Holder Energy | mock-data-holder-energy |
Mock Data Recipient | mock-data-recipient |
If running locally, each of these host names can be registered in the local machine's host
file:
127.0.0.1 mock-register
127.0.0.1 mock-data-holder
127.0.0.1 mock-data-holder-energy
127.0.0.1 mock-data-recipient
You can switch out one of the mock solutions running in the multi-container Mock CDR Ecosystem with a mock solution running in MS Visual Studio or with your own solution.
Within the docker-compose.Ecosystem.yml
file, comment out the solution that you do not want to be started by the docker compose file. Next, change all ASPNETCORE_ENVIRONMENT settings to use the Container setting.
ASPNETCORE_ENVIRONMENT=Container
Start the Mock Solutions using the docker compose file.
# Run the Mock and SQL Server containers.
docker-compose -f docker-compose.Ecosystem.yml up -d
In this example we will be switching out our Mock Data Recipient.
Clone the Mock Data Recipient repository from GitHub and open the solution in MS Visual Studio.
Changing the ASPNETCORE_ENVIRONMENT
setting to use the Container
settings will allow the Mock Data Recipient to connect to the mock solutions running in the multi-container Mock CDR Ecosystem.
We are using the database connection string Server=host.docker.internal and the endpoints shown below to connect to the running containers.
Build and run the Mock Data Recipient in MS Visual Studio. Our switched out Mock Data Recipient solution will now be running. This will result in the Mock Data Recipient running in MS Visual Studio, connected to the Mock Register and the Mock Data Holder running in docker.
For more details on how to run a mock solution in MS Visual Studio see help guide.
The host names used in the mock solutions can be changed by overriding environment variables in each container.
For example, making the following changes to the docker-compose.yml
file will set the host name for the Mock Register to localhost
:
mock-register:
container_name: mock-register
image: consumerdataright/mock-register
ports:
- "7000:7000"
- "7001:7001"
- "7006:7006"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
- ASPNETCORE_ENVIRONMENT=Release
- IssuerUri=https://localhost:7000/idp
- JwksUri=https://localhost:7000/idp/.well-known/openid-configuration/jwks
- TokenUri=https://localhost:7001/idp/connect/token
- IdentityServerTokenUri=https://localhost:7001/idp/connect/token
- IdentityServerUrl=https://localhost:7000/idp
- IdentityServerIssuer=https://localhost:7000/idp
Similar environment variables can be set in the docker-compose.Ecosystem.yml
file to set the host names of the other mock solutions.
The environment variables for each mock solution that require setting in order to update the host names are as follows:
If the host names are changed, then the data stored in the Mock Register should be updated to reflect the updated mock solution endpoints.
This can be achieved by using the Admin API, as outlined in the solution README.
The mock solutions can also be hosted on your own infrastructure, such as virtual machines or kubernetes clusters, in your private data centre or in the public cloud.