Say I have a dockerfile that initializes a certain directory during the build phase.
When I run it from the docker hub like: docker run -v /some/local/directory:/var/lib/mysql nameoffile:latest
the files get initialized in the proper directory on my home pc.
But when I build the file locally from a Dockerfile with the docker build command, and then run the image that was created, the image has already been initialized with the directory /var/lib/mysql in a docker volume at /var/lib/docker/volumes/sdjhsdjfsd67… and my intended destination for that directory is empty.
So how do I run or build a local Dockerfile with a volume pointing to a location where I want it to be?
The trick is to make a separate script that initializes any directories/volumes and starts whatever deamon the dockerfile was built for. Then in the end of the dockerfile with CMD, run that script.