Anton L.
09/08/2025, 8:54 PMMarvin
09/08/2025, 8:54 PMMarvin
09/08/2025, 9:04 PM/mount/efs/...
), the flow-run containers will not see it. Docker will try to bind-mount /mount/efs/...
from the actual host; if that path doesn’t exist there, Docker just creates an empty directory on the host and mounts that. That matches your symptoms: you see persistence between runs (the host dir keeps the data) but not the EFS content or new files you add.
How to confirm quickly
- On the Docker host (not inside the worker container):
ls -ld /mount/efs/.prefect/storage
If that path does not exist or is empty on the host, that’s the issue.
Other common causes to check
- User/home mismatch: The path you mounted is /root/.prefect/storage
, but if your image runs as a non-root user (e.g., prefect
), Prefect’s home will be /home/prefect/.prefect
. In that case, the mount won’t line up. Inside a flow-run container, check:
whoami
echo "$HOME"
prefect settings view | grep PREFECT_HOME
- SELinux: On SELinux-enabled hosts (RHEL/CentOS/Fedora), bind mounts to NFS/EFS often need relabeling. Add :z
or :Z
to your volume string:
/mount/efs/.prefect/storage:/root/.prefect/storage:rw,z
- Permissions/UID/GID: EFS enforces POSIX permissions and may root-squash; ensure the UID/GID running in the container has read/write perms on the EFS path on the host.
Recommended fixes
- If your worker runs in a container:
- Mount EFS on the Docker host itself at the same path (easiest), then keep your pool volume as:
/mount/efs/.prefect/storage:/root/.prefect/storage:rw,z
- Or change the volume source to a host path that does exist and points to your EFS mount.
- Ensure you’re mounting to the path Prefect actually uses in your flow-run containers:
- Option A: Set PREFECT_HOME
in the work pool “Env” so it matches your mount:
PREFECT_HOME=/root/.prefect
- Option B: If running as a non-root user, mount to /home/prefect/.prefect/storage
instead.
- Make the result storage explicit in your deployment so there’s no ambiguity:
from prefect.filesystems import LocalFileSystem
storage = LocalFileSystem(basepath="/data/prefect-storage")
app = flow.from_source("<https://github.com/your/repo>")
app.deploy(
name="my-deploy",
work_pool_name="your-docker-pool",
image="your/image:tag",
result_storage=storage,
)
Then mount your EFS to /data/prefect-storage
in the pool volumes:
/mount/efs/.prefect/storage:/data/prefect-storage:rw,z
Helpful debugging trick
- Temporarily keep the container around so you can exec in and inspect mounts:
- In your Docker work pool’s base job template set auto_remove
to false
and (for a test run) override the command to:
sleep 600
- Then:
docker exec -it <container_id> sh
mount | grep prefect
ls -l /root/.prefect/storage
prefect settings view | grep PREFECT_HOME
If you can share:
- Whether the worker is running on the host or inside a container
- The image you’re using and which user it runs as
- Whether the Docker host uses SELinux
- The “Mounts” section from docker inspect
of a flow-run container
…I can give you an exact, minimal set of changes to make this work. For reference on customizing the Docker work pool job template, see:
- Prefect 3.x Docker guidance (general Docker setup; job template is edited via the work pool)
- You can also view the default Docker job template structure with:
prefect work-pool get-default-base-job-template --type docker