How to create a shared Docker volume (Fedora 35)?

I’ve successfully installed Docker, confirmed that the newly-created container works, installed and run some container images. Sadly I can’t find a way to create a volume to share data between host and the container — I’ve tried two approaches:

docker run -i -v $PWD/docker-shared:/shared:Z -it ubuntu bash

…the directories don’t appear to be shared. The folders /docker-shared and /shared exist on the host and container, respectively.

I’ve used the Z flag due to permission errors, but certainly seems best avoided if possible.

docker run -d -P --name test-container -v /home/user/docker-shared:/shared ubuntu

…returns You cannot attach to a stopped container, start it first error when running docker attach <ID>.


I’ve started anew once by clearing the container data. Feel free to recommend any alternatives (incl. Podman) when the goal is to run CLI software isolated from the host, with a shared directory.