Docker for JHipster in Production mode

A few weeks ago I started a new personal project using JHipster. JHipster is a great Yeoman generator used to generate a complete Spring application on the server side and AngularJS on the client side. Julien Dubois, the lead developer of this project, has done a excellent job putting a bunch of technologies all together (here you can find a complete list of all the technologies used).

In the Jhipster project, you can find a docker container which includes all the necessary libraries for running your project in development mode. Nevertheless, a docker container for production mode is missing.

What does this docker include?

The present docker is an extension of Dubois docker, including a MySql database, Grunt, Bower, and a bash script which creates a database and runs the application using the production profile.


To obtain the docker image you will need to have installed Docker and run the following command:

 docker pull ignaciosuay/jhipster-docker

Once the image is downloaded, you will need to run your application inside the container and forward all local ports exposed (8080 for tomcat, 9000 and 35729 for grunt, 22 for ssh and 3606 for mysql). Try running the following command  and don’t forget to change “your_app_folder” to your local path:

 sudo docker run -v ~/your_app_folder:/jhipster -p 8080:8080 -p 9000:9000 -p 35729:35729 -p 4022:22 -p 3306:3306 -t -i ignaciosuay/jhipster-docker /bin/bash

Finally you will need to run the script in /usr/local/bin, to start the mysql service and run the application using the production profile.

 sh /usr/local/bin/


Change the database name

By default, the script will start the mysql service and will create a database called “jhipster”. If you would like to change the database name, you will need to modify the script on /usr/local/bin/


# Start mysql service and create a database called jhipster
service mysql start
MYSQL=`which mysql`

# Run your project in production mode.
# You need to run it as a jhipster user because 
# some of the tools are not meant to be run by the root user
cd /jhipster
sudo -u jhipster -H sh -c "mvn -Pprod spring-boot:run"</pre>

Use your favourite editor and add your database name at the end of the line 6, instead of “jhipster”.

Start Grunt

If you would like to see any change on the client side and reload your web application instantly then you will need to run the grunt server task. For this purpose, you will need to open a new terminal, access to your container and run grunt following these steps:

  1. Open a new terminal
  2. Get your container ID or name
    1. List your active containers by running:
       sudo docker ps
    2. Copy the container Id or the name
  3. Access your container:
     sudo docker exec -i -t CONTAINER_ID bash
  4. Start grunt serve task:
     grunt serve


You may also like...

2 Responses

  1. Dipayan says:

    I followed your instructions and got the latest version of the docker file for jhipster, I however get a error:
    unable to find gruntfile or unable to find local grunt.

    This is the first time I am using docker, any help will be appreciated.

    • Ignacio Suay says:

      Hi Dipayan,

      It looks like you are trying to run the command “grunt serve” in a folder which doesn’t contains a Gruntfile.js file. I can imagine 2 possible scenarios why this has happen:

      1) You haven’t copy your project inside your folder. When you start your container you should run the following command:
      sudo docker run -v ~/your_app_folder:/jhipster -p 8080:8080 -p 9000:9000 -p 35729:35729 -p 4022:22 -p 3306:3306 -t -i ignaciosuay/jhipster-docker /bin/bash
      You need to be sure that the path to your local project is correct (~/your_app_folder:/jhipster). Everything in that folder will be copied to /jhipster inside your container.

      2) Once you are logged in your container you need to be sure that you are in the correct path. In this case, I have copied my project to /jhipster folder, so inside this folder you will need to run: grunt serve.

      Hope it helps! Please let me know if you have any comments or queries.

Leave a Reply

Your email address will not be published. Required fields are marked *