CaMicroscope and all its components are available as a Docker Distribution. At first, I thought it would be something really really complex. But fortunately, all I had to use about docker was to build and up the container. But as I started to understand how the whole stack comes together, I got interested!

The issue I faced was that everytime I made any changes to the viewer, I had to rebuild the container. This was quite annoying. I googled but didn’t find any satisfactory results. So, I asked my mentors and they suggested to mount the volume. So I went ahead and read about the file system of docker and volumes.

Docker File System

Docker container is created from a read-only template called docker image. Each Docker image references a list of read-only layers that represent filesystem differences. Layers are stacked on top of each other to form a base for a container’s root filesystem. The Docker storage driver is responsible for stacking these layers and providing a single unified view. When we start a container, Docker takes the read-only image and adds a read-write layer on top. If the running container modifies an existing file, the file is copied out of the underlying read-only layer and into the top-most read-write layer where the changes are applied. The version in the read-write layer hides the underlying file, but does not destroy it — it still exists in the underlying layer. When the container is deleted the read-write layer is also deleted but the underlying image remains unchanged. Docker calls this combination of read-only layers with a read-write layer on top a Union File System.

The solution to the issue I faced was volumes. It is Docker’s mechanism for managing files outside the lifecycle of the container. It allows accessing files on the host from the container. In other words, volumes are directories (or files) that are outside of the default Union File System and exist as normal directories and files on the host filesystem.

Since we’re using docker-compose as it’s multi-container environment, all I had to do was to add ../caMicroscope/apps:/var/www/html/apps under the volumes of the viewer in the config file. I really enjoyed the concept of docker!