How to Run Mule 4 In Docker Container
Recently I updated javastreets/mule
docker image to Mule 4.4.0 Kernel (community edition). In this post, we will run a Hello Mule 4 application in Docker container.
1. What is Mule Docker Image?
If you are looking for Mule 4 Kernel Docker image, then you can check javastreets/mule
docker image on docker hub.
If you have Docker installed on your machine, you can pull the image with docker pull javastreets/mule
.
2. Say Hello Mule 4 Application
I have added a Simple Hello Mule 4 application to mule4-examples repository on GitHub. This application has only one HTTP listener flow that listens on http://localhost:8081/test/hello.
It is built for Mule 4.4.0 Community Edition Runtime.
3. Dockerfile
The Dockerfile to build and package our application to mule -
FROM javastreets/mule:latest
COPY ./target/say-hello-mule4-docker*.jar /opt/mule/apps/ (1)
CMD [ "/opt/mule/bin/mule"]
1 | When Maven builds the Mule 4 application, it generates {your-mule-application-name}.jar file under target folder. Example application name is say-hello-mule4-docker . This step copies that jar file to Mule running inside container. Change the name in this step to match your application. |
4. Build and Run
To build and run the application - execute sh buildAndRun.sh
.
This performs 3 steps -
-
Run Maven Build to package application.
-
Build Docker image named hellomule4 and adds this application to Mule within docker.
-
Starts the docker container to run mule in foreground. (press CTRL+C to stop mule)
To run application in background, you may also run below command -
docker run -d --name hellomule4 -p 8081:8081 hellomule4
This docker image exposes 8081 port and binds it to the 8081 of localhost.
Once application is running, access below url to see Hello from Mule -
It should output -
Hello from Mule ESB (Version: 4.4.0-20221024). I am running inside docker image javastreets/mule.
5. Conclusion
It is easy to run Mule Applications inside Docker Containers. javastreet/mule docker image provides an easy way to get Mule Up and Kicking! Example source code is available on Github here - mule4-examples
Stay updated!
On this blog, I post articles about different technologies like Java, MuleSoft, and much more.
You can get updates for new Posts in your email by subscribing to JavaStreets feed here -
Lives on Java Planet, Walks on Java Streets, Read/Writes in Java, JCP member, Jakarta EE enthusiast, MuleSoft Integration Architect, MuleSoft Community Ambassador, Open Source Contributor and Supporter, also writes at Unit Testers, A Family man!