DEV Community

Manik Magar
Manik Magar

Posted on • Originally published at javastreets.com on

How to Run Mule 4 In Docker Container

Recently I updated javastreets/mule docker image to Mule ESB 4.1.0 Community version. In this post, we will run a Hello Mule 4 application in Docker container.

Table of Contents

  • 1. What is Mule Docker Image?
  • 2. Say Hello Mule 4 Application
  • 3. Dockerfile
  • 4. Build and Run
  • 5. Conclusion

1. What is a Mule Docker Image?

If you are looking for Mule Docker image, then you can check javastreets/mule docker images on docker hub. It is probably the smallest and compact Mule ESB Image.

If you have Docker installed on your machine, you can pull the image as 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 current Mule 4 Community Edition Runtime.

3. Dockerfile

The Dockerfile to build and package our application to mule -

FROM javastreets/mule:latest-4

COPY ./target/say-hello-mule4-docker*.jar /opt/mule/apps/

CMD ["/opt/mule/bin/mule"]

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 -

http://localhost:8081/test/hello

It should output -

Hello from Mule ESB (Version: 4.1.0). I am running inside docker image javastreets/mule:latest-4

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

Top comments (6)

Collapse
 
pruggera profile image
Phil Ruggera

Let's say I want to run 500 Mule apps. How would we reduce the RAM consumption due to all those JVMs and Mule ESBs running in all those containers?

Collapse
 
isenseem profile image
Isenseem

Hi, Im new to Anypoint and Docker.

How can I "execute sh buildAndRun.sh." ?
I would like to execute it in a termial, but I wasn´t able to find one in Anypoint.

Or should we use PowerShell an follow the path in the project directory?

Collapse
 
mickaelbaye profile image
Mickaël B

Hello. I tried the example and it's not working. We can see in the logs that mule server is started but the application is not deployed.

Collapse
 
manikmagar profile image
Manik Magar

Hi Mickael,

I just tried it by following the steps in the post and application started -

 ✝  git/mule4-examples/say-hello-mule4-docker   master  curl http://localhost:8081/test/hello
Hello from Mule ESB (Version: 4.1.1). I am running inside docker image javastreets/mule.%

Collapse
 
mickaelbaye profile image
Mickaël B

Hello again. It was a mistake on my side.
This is great! :)

Thread Thread
 
manikmagar profile image
Manik Magar

Glad to know that you found it helpful!