Things I couldn’t find elsewhere

Rootless Docker and home folder shenanigans

Docker · English · Uncategorized

2 minutes

Docker is a powerful tool for managing and deploying applications, but it can sometimes be frustrating to work with. In this post, I want to share my experience with a recent issue I had with rootless Docker, and what I did to resolve it.

I was working on a project when I suddenly realized that a Dockerfile wouldn’t build on my regular desktop user account. Any command that I ran after the FROM command would just spit out “invalid argument”. I was confused, because I have multiple users on this machine running Docker and my main user was the only one with any issues.

I spent a long time comparing the output of the docker info command between different accounts. Eventually, I noticed that all the working ones were using the overlay2 filesystem, while the one that wasn’t working was using vfs. It didn’t take too long to realize that my main user is the only one with an encrypted $home directory, which meant that using it as the data directory for Docker was not possible.

To fix the issue, I created a ~/.config/docker/daemon.json file containing an entry for data-root that pointed to a directory outside of the encrypted $home. This allowed the overlay2 filesystem to be used again, and I was able to build the Dockerfile without any issues.

I’m not sure why this issue ever worked before, but it’s possible that it was because I was running Docker in a different way (e.g. without rootless mode). I searched online for solutions to this problem, but I didn’t find many helpful hints. In the end, I had to figure it out on my own.

In conclusion, working with Docker can be challenging at times, but with some perseverance and a willingness to experiment, you can overcome most issues. In my case, the solution was to use a different filesystem and to point to a non-encrypted data directory. I’m glad that I was able to figure it out, and I hope that my experience can help others who may be facing similar issues.

***

Did this post seem a bit out of character for me? Well, then you should go read the original Mastodon thread. This writeup comes courtesy of ChatGPT, asked to rewrite said thread into an essay.