Docker Container mount to a mysteric folder which I don't know where is it.

Env:  Ubuntu 20.04

 When install too many versions of docker on the same machine,  it could have a weird mount behavior.

I have a folder called /media/xxx/uuid/prod/db, hereafter, "local db folder".   and I mount this folder to the /db folder inside container, hereafter "container db folder".   

I start container like this: 

docker run --rm --mount type=bind,source=/media/xxx/uuid/prod/db,target=/db image:latest

As you can expected, something happened.

the container was  up and running.  the mount seemed not right.

If I add a new file to the local db folder, the new file was not available in container db folder,  and vice versa,  if I add a new file to the container db folder,  the file wasn't available in the local db folder either.   Looks like the local db folder and container db folder wasn't mapped.  

Run docker inspect, I could see the mount configure was correct, from /media/xxx/uuid/prod/db to /db

However, if I stopped the container, and create a new container,  the file created in the container db folder was still there.

So the container db folder was mapped  to a folder on the local computer,   but not /media/xxx/uuid/prod/db folder.  even i specified the source is /media/xxx/uuid/prod/db and I searched the computer, I couldn't locate the new file I created in the container db folder.

I did a few more tests,  one test is try to bind a non-existing folder, then I saw an error message that the source /host_mnt//media/xxx/uuid/prod/new-db was not found

Then I googled a few post,  get inspiration from this post.  The issue there was the author had different versions of docker installed on his ubuntu.  The solution is uninstalled them and follow the instruction to installed a new docker. 

So I uninstalled all the docker and delete docker daemon.  

After that,  the mount works correctly. 


Look back,  I think the issue was introduced when I installed the old version of docker-compose which are not supported anymore.  the right way now is use compose as a command of docker.  

Comments

Popular posts from this blog

Such a cold summer

My Unsolve Questions