Eddú Meléndez

Dockerizing Mule ESB

Creating a Dockerfile for MuleESB

Let’s create our Dockerfile

1
vim Dockerfile

We will build our Mule ESB Standalone Server image based on java version 8 from Docker Hub Java repository. More info about FROM

1
FROM java:8

We will use two environment variables MULE_HOME and MULE_VERSION, which will be used in our Dockerfile. More info about ENV

1
2
3
ENV MULE_HOME /opt/mule

ENV MULE_VERSION 3.7.0

Now, we need to download the latest version of Mule Standalone Server from Mulesoft’s repository in /opt folder, unzip it and rename the folder to mule. Additionally, zip file will be deleted. Since, we are running over Linux (Ubuntu) we can use some useful commands. More info about RUN

1
2
3
4
5
6
RUN set -x \
        && cd /opt \
        && curl -o mule.zip https://repository.mulesoft.org/nexus/content/repositories/releases/org/mule/distributions/mule-standalone/$MULE_VERSION/mule-standalone-$MULE_VERSION.zip \
        && unzip mule.zip \
        && mv mule-standalone-$MULE_VERSION mule \
        && rm mule.zip*

Then, we will locate at $MULE_HOME folder. More info about WORKDIR

1
WORKDIR $MULE_HOME

Now, we will expose some folder inside of mule in order to have access from outside of docker container. More info about VOLUME

1
2
3
4
VOLUME $MULE_HOME/apps
VOLUME $MULE_HOME/conf
VOLUME $MULE_HOME/domains
VOLUME $MULE_HOME/logs

Finally, we need to start the server. More info about ENTRYPOINT

1
ENTRYPOINT ["./bin/mule"]

Our final Dockerfile looks like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
FROM java:8

MAINTAINER Eddú Meléndez <eddu.melendez@gmail.com>

ENV MULE_HOME /opt/mule

ENV MULE_VERSION 3.7.0

RUN set -x \
        && cd /opt \
        && curl -o mule.zip https://repository.mulesoft.org/nexus/content/repositories/releases/org/mule/distributions/mule-standalone/$MULE_VERSION/mule-standalone-$MULE_VERSION.zip \
        && unzip mule.zip \
        && mv mule-standalone-$MULE_VERSION mule \
        && rm mule.zip*

WORKDIR $MULE_HOME

VOLUME $MULE_HOME/apps
VOLUME $MULE_HOME/conf
VOLUME $MULE_HOME/domains
VOLUME $MULE_HOME/logs

ENTRYPOINT ["./bin/mule"]

Building the MuleESB Docker image

In order to have the image available in your local machine we just need to execute the command below:

1
docker build --tag eddumelendez/mule  .

Running the MuleESB Docker image

1
docker run -ti eddumelendez/mule

You can find the final example on my github repository docker-mule

Comments