Running MQ .NET Core Application on Docker containers

 View Only

Running MQ .NET Core Application on Docker containers 

Wed March 04, 2020 01:46 PM

Running MQ .NET Core Application on Docker containers

Harsha Ketaraju

Published on 14/08/2019

Introduction:
This blog gives you an overview on how to run a MQ .NET Core Application on docker containers.

Create Project Folder:

  1. Create a new folder by name “SimplePut”.
  2. Copy SimplePut.cs and SimplePut.csproj files to the SimplePut folder created in Step 1 from the following location:
    Windows:
    MQ_INST_PATH\tools\dotnet\samples\cs\core\base\SimplePut
    Linux:
    MQ_INST_PATH/samp/dotnet/samples/cs/core/base/SimplePut
  3. Remove the following line from SimplePut.csproj file
    <HintPath>..\bin\amqmdnetstd.dll</HintPath>
  4. Copy amqmdnetstd.dll file to the SimplePut folder created in Step 1 from the following location:
    Windows:
    MQ_INST_PATH\bin
    Linux:
    MQ_INST_PATH/lib64

Create a DockerFile for MQ .NET Core Application:

  1. Create a file by name “DockerFile” in SimplePut project folder which will be used as Dockerfile for sample application to build docker image.
  2. Add the below mentioned text to your DockerFile for either Windows Containers or Linux as follows:
  1. FROM microsoft/dotnet:latest
  2. WORKDIR /app
  3. #copy csproj and restore as distinct layers
  4. COPY *.csproj ./
  5. COPY *.dll ./
  6. RUN dotnet restore
  • #copy and build everything else
  • COPY . ./
  • RUN dotnet publish -c Release -o out
  • ENTRYPOINT ["dotnet", "out/SimplePut.dll"]

Build the Docker Image:

  1. Open command prompt to build the docker image.
  2. To verify whether docker is installed or not, issue the following command on command line as follows:
    docker -v
    Output:
    Docker version 18.09.0, build 4d60db4
    If not, please install Docker for Linux/windows containers from Docker website.
  3. Navigate to your project folder and use the below command to build your Docker image.
    docker build -t simpleput .
    Note: Image_name should be lowercase alphabets.
  4. Docker image with simpleput will be successfully created. Output as follows:
  1. Sending build context to Docker daemon 381MB
  2. Step 1/8 : FROM microsoft/dotnet:latest
  3. ---> 81d80198a492
  4. Step 2/8 : WORKDIR /app
  5. ---> Using cache
  • ---> 72afa181c56c
  • Step 3/8 : COPY *.csproj ./
  • ---> Using cache
  • ---> 43bbfd1b9635
  • Step 4/8 : COPY *.dll ./
  • ---> Using cache
  • ---> 4d81184ca6e3
  • Step 5/8 : RUN dotnet restore
  • ---> Using cache
  • ---> f250db37f272
  • Step 6/8 : COPY . ./
  • ---> Using cache
  • ---> 7bd622f5fead
  • Step 7/8 : RUN dotnet publish -c Release -o out
  • ---> Using cache
  • ---> 2f8cb551ef9a
  • Step 8/8 : ENTRYPOINT ["dotnet", "out/SimplePut.dll"]
  • ---> Using cache
  • ---> a9f01505ea8d
  • Successfully built a9f01505ea8d
  • Successfully tagged app:latest
  1. By issuing the following command, you can view the latest docker image created.

docker images

  1. Output for the above command as follows:

REPOSITORY

TAG

IMAGE ID

CREATED

SIZE

simpleput

latest

a9f01505ea8d

21 seconds ago

1.75 GB

Running the Docker Image:

  1. Run the docker image by passing arguments as follows:
    docker run simpleput -qm Test1 -q Q1 -h 9.yyy.zzz.ww -p 1423
  2. Program will be putting messages successfully onto the queue which is mentioned as arguments.
  1. Start of SimplePut Application
  2. MQ Parameters
  3. 1) queueName = Q1
  4. 2) keyRepository =
  5. 3) cipherSpec =
  6. 4) host = 9.yyy.zzz.ww
  7. 5) port = 1423
  • 6) channel = SYSTEM.DEF.SVRCONN
  • 7) numberOfMsgs = 1
  • 8) sslPeerName =
  • 9) keyResetCount = 0
  • 10) sslCertRevocationCheck = False
  • Connecting to queue manager.. done
  • Accessing queue Q1.. done
  • Message 1 <test message>.. put
  • Closing queue.. done
  • Disconnecting queue manager.. done
  • End of SimplePut Application

References:
Installing IBM MQ classes for .NET Standard

 

Entry Details

Statistics
0 Favorited
13 Views
1 Files
0 Shares
4 Downloads
Attachment(s)
pdf file
Running MQ NET Core Application on Docker containers.pdf   124 KB   1 version
Uploaded - Wed March 04, 2020

Tags and Keywords

Comments

Tue April 18, 2023 01:16 AM

Hi, we are currently moving a .NET 6 application into a docker Linux container. The application have previously been hosted on a windows server. Where it have been able to fetch certificate for authentication against the Queue manager from the windows certificate store, using the certificate label.
But now we are facing the problem on how to add the certificate into the linux container and make the application being able to use the certificate when authenticating.

Any ideas if there is any differences that needs to be taken into consideration when accessing certificate in a linux container vs windows?

Related Entries and Links

No Related Resource entered.