From 71423233bd6f91a903895b76bf856c06024e25d0 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 5 Aug 2021 12:55:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fix=20Tomcat=20volume=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New Tomcat image (version 9) doesn't load any example webapp by default, but ships with examples in webapps.dist. Let's use this as an opportunity to demonstrate how to populate empty volumes from container directories. Closes #561. --- slides/containers/Working_With_Volumes.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/slides/containers/Working_With_Volumes.md b/slides/containers/Working_With_Volumes.md index bc598775..5753214a 100644 --- a/slides/containers/Working_With_Volumes.md +++ b/slides/containers/Working_With_Volumes.md @@ -159,6 +159,24 @@ Volumes are not anchored to a specific path. --- +## Populating volumes + +* When an empty volume is mounted on a non-empty directory, the directory is copied to the volume. + +* This makes it easy to "promote" a normal directory to a volume. + +* Non-empty volumes are always mounted as-is. + +Let's populate the webapps volume with the webapps.dist directory from the Tomcat image. + +````bash +$ docker run -v webapps:/usr/local/tomcat/webapps.dist tomcat true +``` + +Note: running `true` will cause the container to exit successfully once the `webapps.dist` directory has been copied to the `webapps` volume, instead of starting tomcat. + +--- + ## Using our named volumes * Volumes are used with the `-v` option.