How to mount host directory in while creating Docker Image?

I am trying to create Docker Image which itself has mount point to some directory in Docker Host.
So when I create container with “docekr run”(without -v) using the Image I created it should come up with the mounted directory to the docker host. Is it possible?

1 Like

It would be helpful if you share the Dockerfile for creating your image, but in general in order to mount a host directory you need to create a Volume first and then point the volume to the appropriate PATH, In case you want to do run the image directly I suggest you use docker-compose. Define a docker-compose.yml with a Volume and your Image details and then run all with docker compose up. Check also here is a very good guide regarding volumes.