From ebf59f0a83a597250a040517b4e12a015e874ca5 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Mon, 29 May 2023 13:55:18 -0500 Subject: [PATCH] docs: clarify bind mounts for Podman also (#2157) --- docs/data-directory.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/data-directory.md b/docs/data-directory.md index 36737420..db0574ff 100644 --- a/docs/data-directory.md +++ b/docs/data-directory.md @@ -8,7 +8,7 @@ Everything the container manages is located under the **container's** `/data` pa ### Attaching data directory to host filesystem -In most cases the easiest way to persist and work with the minecraft data files is to use the [volume mounting](https://docs.docker.com/storage/volumes/) `-v` argument to map a directory on your host machine to the container's `/data` directory. In the following example, the path `/home/user/minecraft-data` **must be** a directory on your host machine: +In most cases the easiest way to persist and work with the minecraft data files is to use [bind mounts](https://docs.docker.com/storage/bind-mounts/) with the `-v` argument to map a directory on your host machine to the container's `/data` directory. In the following example, the path `/home/user/minecraft-data` **must be** a directory on your host machine: -v /home/user/minecraft-data:/data ------------------------- ----- @@ -19,6 +19,15 @@ In most cases the easiest way to persist and work with the minecraft data files When attached in this way you can stop the server, edit the configuration under your attached directory and start the server again to pick up the new configuration. +!!! important "Rootless, Podman, SELinux, AppArmor usage" + When running rootless containers, such as with Podman, or using SELinux / AppArmor on your system, append ":Z" to the volume mapping. For example: + + ``` + /home/user/minecraft-data:/data:Z + ``` + + There might be a safer/better way to accommodate these systems. Please post an issue or PR if you have more information. + With Docker Compose, setting up a host attached directory is even easier since relative paths can be configured. For example, with the following `docker-compose.yml` Docker will automatically create/attach the relative directory `minecraft-data` to the container. ``` yaml title="docker-compose.yml" @@ -39,10 +48,6 @@ services: - ./minecraft-data:/data ``` -!!! note - - if you have SELinux enabled, then you might need to add `:Z` to the end of volume mount specifications, [as described here](https://prefetch.net/blog/2017/09/30/using-docker-volumes-on-selinux-enabled-servers/). - ### Converting anonymous `/data` volume to named volume If you had used the commands in the first section, without the `-v` volume attachment, then an anonymous data volume was created by Docker. You can later bring over that content to a named or host attached volume using the following procedure.