October 5, 2021

Using Diffusion with Docker: Volumes

In our tutorial on Using Diffusion with Docker, we saw how to pull a Diffusion image, start the server, and use a Dockerfile to build your own image on top of Diffusion. In this tutorial, we will look at using Docker Volumes to enable custom configuration and persistence on your Diffusion server, without the need for a Dockerfile. If you are unfamiliar with Docker Volumes we recommend reviewing the official documentation 

If you haven’t already, pull the default image of Diffusion, remembering to specify the required version.  

docker pull pushtechnology/docker-diffusion:6.7.1  

If we run the default image, make some configuration changes on the server, and then stop the container, we will see that the changes have not been persisted when we run the image again. 

Next, we will use the docker volume create command to create a volume with a name of our choice.  

docker volume create diffusion-volume 

To run our image with the volume we will use the -v tag which takes the name of the volume and the destination where the volume will be mounted, in our case this is /opt/diffusion which will allow us to persist all the files for this Diffusion instance. 

docker run -p 8080:8080 -v diffusion-volume:/opt/diffusion pushtechnology/docker-diffusion:6.7.1 

Now, when we run the image, make some configuration changes on the server, and then stop the container, we will see that the changes have been persisted when we run the image again. 

We can test the persistence by saving a new file on a running container.  

Run your image with the volume mounted as above, however this time us the -d tag to run the container in the background 

docker run -d -p 8080:8080 -v diffusion-volume:/opt/diffusion pushtechnology/docker-diffusion:6.7.1 

Obtain the name of your running container with docker ps, then use the following command to obtain a shell on your container. 

docker exec -it <name> /bin/sh 

Create a test file and then exit the shell and kill the container. 

diffusion volumes in the terminal

Now repeat the steps above to run the image and obtain a shell. You will see that our test file ‘hello’ has been persisted and is available in our new container. 

diffusion volumes terminal

You can now save custom configuration files, licenses, and security stores in dedicated volumes which you can mount as needed. 

 
 
diffusion

Enjoy the rich functionality of Diffusion 6.7 as part of your event-driven application.

diffusion
Quick Start Guide

Step-by-Step guides to get started

diffusion
Diffusion Cloud

SaaS offering to focus on business

diffusion
Diffusion On-Premise

A holistic pub-sub platform for real-time apps