Create an ActiveMQ image and push it to your own docker hub account !

bilal asif mirza
4 min readMay 3, 2020

--

In the first part of these tutorials , I will explain and tell how to

  • How to create an activemq docker image .
  • How to push that image in a docker hub account , so that others can use your image !

Creating an ActiveMQ Docker image from scratch

  1. Download Activemq distribution zip from https://activemq.apache.org/components/classic/download/ .
    Here I have downloaded the .tar file for linux .
  2. Now in order to create a docker image , we would need a Dockerfile which is like the blueprint of your docker image .
    The Dockerfile in our case would be simply doing the following things :
  • Copy the activemq directory in our image
  • and starting activemq server up .

3. Open up any text editor and write the below contents in it .

# Using jdk as base image
FROM openjdk:8-jdk-alpine
# Copy the whole directory of activemq into the image
COPY apache-activemq-5.15.12 /opt/apache-activemq-5.15.12
# Set the working directory to the bin folder
WORKDIR /opt/apache-activemq-5.15.12/bin
# Start up the activemq server
ENTRYPOINT ["./activemq","console"]

FROM command specifies the base image where our image will sit on .

COPY command simply copies the whole activemq directory inside our image

WORKDIR specifies the working directory of the image where we can then perform additional tasks.

ENTRYPOINT is where you mention any command that will be executed whenever the container will start .

4. Now save the above file naming it Dockerfile (without any extension ) outside the activemq’s root folder like so :

The Dockerfile should exist where the root dir of activemq is

5. Next up , open the terminal and execute the following command to build our image .

docker build -t bam1996/activemq-custom:latest .

( Notice the . at the end , this is telling docker that our Dockerfile is existing the same place we are executing the command from shell )

Here bam1996 is my docker account id , you will be using your own docker account id when you will create an account otherwise it will not work !

You will see output something like this :

The output above shows the image building process , each command we wrote is being executed one by one as a separate docker layer

You can see your docker image by executing docker images .

Here the first entry is our newly created image ( activemq-custom ) .

That concludes the first part where we just build the image .

Now for the second part , we are going to push our image into our docker hub account . For this we need to create a docker hub account first ! .

  1. Go to the official docker hub webpage and create an account : https://hub.docker.com/signup .
  2. After creating your account , you can see your docker hub account .
Your docker hub account .

3. Here my account id is bam1996 , it will be unique to yours . We will be using this account id to push our images and to login .

4. Now that we have a docker hub account , we need to login to our docker hub account from our machine so that we can push the image . Execute the following command and enter your account id and password :

docker login -u *your-account-id* -p *your-password-here*

5. When you have logged in , you can now push your image .

docker push bam1996/activemq-custom:latest

The syntax is docker push account-id/image-name:tag

You will see all the layers being pushed one by one . \

6. After that go to your docker hub account and you will see our new image over there :

Now if you want to pull your docker image from your docker hub , then simply run the following command :

docker pull *your-docker-account-id*/activemq-custom

( Dont forget to remove the existing image we made , otherwise it will not download the image )

And that’s it ! You just created an activemq docker image from scratch and pushed it to your docker hub account ! Nice !

So far we have done the following things :

  1. Created an activemq docker image from scratch .
  2. Created a docker hub account , logged in and pushed our activemq image .
  3. Pulled our newly pushed docker image from docker hub.

Jump towards the next part for some kubernetes related juicy stuff :
https://medium.com/@bilal.asif.97/setting-up-kubernetes-on-your-local-machine-via-minikube-and-kubectl-96ddb695ca22

--

--