Ubuntu 16.04.2 LTS, MongoDB 3.6
I migrated the /var/lib/docker/ directory to /home/docker/ to free disk space.
mv /var/lib/docker /home/docker
ln -s /home/docker /var/lib/docker
When I run docker run mongo the output is as follows:
2018-03-11T03:00:55.288+0000 I CONTROL [initandlisten] options: { net: { bindIpAll: true } }
2018-03-11T03:00:55.288+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Permission denied
I presume it is the user privilege issue during the migration and chmod -R 777 /home/docker does fix the problem, but I cannot find out where the user privilege problem happened during the docker dir migration.
So, what privilege does mongodb need when set up listener and how could I check if this privilege is not granted after the migration. THANKS.
Could you please provide scripts, Dockerfile, etc to explain your problem. I don't understand how the migration was done.
I just manually move the directory and create a soft link, as updated in the issue above.
I think your "migration" destroyed your docker installation.
A root folder should not be in your /home folder. You probably changed the owner of the files and docker is lost.
If you want to save space on your drive. You should consider :
docker ps -a to list them all.docker run -d --rm -v /home/user/my-mongodb-data:/data/db -p 27017:27017 mongo:3.6.4 so the data is not stored into /var/lib/docker/volumes. This will work only if you have a separated /home partition.Thanks. @MaBeuLux88 Actually the approaches you listed has all been tried before, according to docker's doc. But only the currently used images (no volumes) could fill up the / partition so I had to moved them to separated /home partition.
I have known that it was a wrong "migration" process. Now the system works since I changed the whole docker directory privileges to 777, ignoring safety concerns. Since re-partition of my server is not practical, what am I supposed to do afterwards? Is there a way to re-install the whole docker system on /home partition, or how to investigate the right privileges mongo needs so I could adjust the privileges accordingly?
Frankly, I'd recommend ditching your old "/var/lib/docker" and simply
re-pulling images you need from Docker Hub (or rebuilding them from their
relevant Dockerfile source) rather than trying to migrate it from one drive
to another.
If you've got useful (stateful) data in there, it should all be under
"/var/lib/docker/volumes".
I'm a bit late to this party, but I was just facing a similar issue. I was working on a device which had a partitioned drive, and the partitioning left /var/lib/docker on quite a small drive. Although my patches to my images should've only taken a few MB worth of space, it wasn't possible to load the whole image in via docker load -i image.tar.gz (why that was necessary is another story).
I was left in a situation where two separate images were having these permission errors, so it was pretty obvious that the migration as you call it was the issue.
However, running chmod 777 -R /var/lib/docker seemed a bit loose, so here's a trivial solution:
docker image ls and find all mongo images and docker image rm them)It should free up enough space during the removal to be able to re-load / re-pull them, and then the permission errors won't persist because the docker service will write them in correctly.
Most helpful comment
I'm a bit late to this party, but I was just facing a similar issue. I was working on a device which had a partitioned drive, and the partitioning left
/var/lib/dockeron quite a small drive. Although my patches to my images should've only taken a few MB worth of space, it wasn't possible to load the whole image in viadocker load -i image.tar.gz(why that was necessary is another story).I was left in a situation where two separate images were having these permission errors, so it was pretty obvious that the
migrationas you call it was the issue.However, running
chmod 777 -R /var/lib/dockerseemed a bit loose, so here's a trivial solution:docker image lsand find allmongoimages anddocker image rmthem)It should free up enough space during the removal to be able to re-load / re-pull them, and then the permission errors won't persist because the docker service will write them in correctly.