Recently, I had to create a custom MQ Container on a Windows machine. I was reading through the documentation and decided that the best approach would be to build the container on a Linux WSL subsystem. After a lot of reading I realised that with some additional tooling the process becomes straight forward, but it required that discovery, hence this blog.
First the Windows pre-requisites. There will be some Linux related prerequisites, but we need to get the WSL Linux distribution ready for them.
WSL 2
Of course WSL 2 needs to be enabled.
VS Code
Install VS Code and the remote WSL extension for VS Code. This allows you to run VS Code for the code and tooling on Linux, with the VS Code GUI running in Windows. Much nicer than using VI in Ubuntu.
Podman
Install, initialise and start Podman for windows
Installing a new WSL distribution
Start a “as administrator” terminal,
Check that both client and server for Podman is installed by running:
podman version
Check which WSL distributions have been installed.
wsl -list
On a new clean system, the podman-machine will be the only distribution shown.
Install a new Ubuntu distro.
wsl -install
The default is to install Ubuntu, hence the simplified command.
The install will prompt for a Linux username and password, and then will switch the terminal to the new Ubuntu system.
Starting Ubuntu Terminals
This is an aside, but should you inadvertently close this terminal, there are several ways you can open new Ubuntu terminals.
Launch a new Windows terminal:
wsl -list –running
Will show that you have a new running Ubuntu distribution.
wsl -d Ubuntu -u <your linux username>
Will start an Ubuntu terminal open at the same windows directory, you ran the command from, as a mount on your linux subsystem. As you can see you have access to the whole c:/ drive as /mnt/c on the Linux distro.
A quicker way is to use the drop-down menu to directly launch an Ubuntu terminal
Aside over, we can now,
install a Podman client on the Ubuntu distro
From an Ubuntu terminal install podman client run:
sudo apt-get update
sudo apt-get -y install podman
Verify that only the podman client has been installed
podman version
podman ps
Should show no running containers, but most importantly it should not throw any errors. Indicating that the podman client is able to communicate with the podman server, running in the podman subsystem. That is also why only the client was installed, when installing podman on the Ubuntu subsystem.
Prepare the code
I cloned the container registry into a directory that was readily accessible from both Ubuntu and Windows terminal. The Linux system can be accessed from Windows through a share on \\wsl$ , but I found it easier to navigate to my Windows home drive on the ubuntu distro. This way I can inspect the code from both systems. Remember that the windows c drive is mounted as /mnt/c on the Ubuntu distro.
Linux clones handle symbolic links in git repositories better than Windows clones.
Clone the repository.
git clone -b 9.4.1 https://github.com/ibm-messaging/mq-container
Start VS Code.
cd mq-container
code .
This starts up VS Code with the GUI on windows. Install the WSL extension, so that you can open VS Code with a Linux perspective.
Make your customisations. In my case to enable AMQP.
Build a customised IBM MQ Container
There is one more pre-requisite before the build.
sudo apt install make
It is possible to run a build on the Ubuntu subsystem from a windows terminal.
wsl -d Ubuntu bash -c “make build-devserver COMMAND=podman”
but I preferred to run the build from the Ubuntu distro, which you can do from a VS Code Ubuntu terminal.
make build-devserver COMMAND=podman
podman image ls
Shows the newly build image.
.
It’s now possible to start the container, in my case with an additional port for AMQP.
podman run --env LICENSE=accept --env MQ_QMGR_NAME=QM1 --env MQ_APP_PASSWORD=<…> --env MQ_ADMIN_PASSWORD=<…> --publish 1414:1414 --publish 9443:9443 --publish 5672:5672 --detach ibm-mqadvanced-server-dev:9.4.1.0-amd64
As WSL forwards localhost addresses to its Linux distros, it’s possible to open a browser and access the MQ Console through localhost.
You now have a customised container running, inside a Ubuntu WSL subsystem, that is accessible from the Windows host.