Why are there many ways to do the same thing between docker build and run?
docker build --volume /tmp -t tag . is the same exact thing as adding VOLUME in the Dockerfile. But regardless, these methods aren’t actually doing anything but creating a directory because you still need to bind the volume when you do
docker run --volume /tmp:/tmp tag.
Also, whenever you run a
docker run command with a volume, a new volume is cached (seen with
docker volume ls) which eats up a ton of storage over time without cleanup. An extremely common case with container development is reusing a set of volumes. Is there no way to predefine a set of host-to-container mapping and reference it rather than redefine each volume, kind of like
docker network create.