Persistent and Ephemeral Volumes
There are two types of volumes: persistent and ephemeral ones. What we have seen so far is persistent volumes, which are between the host and the container. To share the volume between containers, we use the --volumes-from
option. This volume exists only as long as it is being used by a container. When the last container using the volume exits, the volume disappears. This type of volume can be passed from one container to the next but is not saved. These volumes are called ephemeral volumes.
Volumes can be used to share log files between the host and the container or between containers. It is much easier to share them on a volume with the host so that even if the container was removed for an error, we can still track the error by checking the log file on the host after the container's removal.
Another common use of volumes in practical microservices applications is sharing the code on a volume. The advantage of this practice is that you...