Just sharing my experience while re installing docker to a new ubuntu installation for future reference for myself. Well hopefully it can help some devs as well, might help wasting a few hours of reading or testing.
I am using Ubuntu 24.04.1 at the moment but this might be applicable to future versions too. I installed a package and it seemed to cause ubuntu to perform a system check but it stops in fsck check. After doing an fsck check via bootable usb drive it still gave me the same error so I decided to re install Ubuntu, which brings me to re installing all the programs I’m using for dev. One of which is docker.
Since it’s been some time since I last installed docker, I went to https://docs.docker.com/engine/install/ubuntu/ and decided to follow one of the instructions. I can’t remember which method I used though, but it installed docker with rootless access and without any error. Then I tried running my dev containers and they were running fine except for some of the codes are failing due to permission issues.
After a few hours of reading I just found out docker is being run as root from the host machine if it’s being run in rootless mode and therefore everything created at the moment of running the container would be owned by that user, including volumes I’m automatically mounting via docker-compose, which includes the source code for my project. I didn’t know this before. The way I understood it is that since the container is being run without root access (from host) the container will be using a default user which is user with ID=0 which is the root (of the container’s system, not root of the host/my machine). Basically the user in the container doesn’t match the user in my machine (host machine).
I tried a couple of solutions I found online and since I am lazy and didn’t want to spend too much time bringing back my previously working setup I decided to just remove docker (https://docs.docker.com/engine/install/ubuntu/#uninstall-docker-engine) and re install it with root access (which is by default if you follow the other installation method). This time i chose Install by package : https://docs.docker.com/engine/install/ubuntu/#install-from-a-package. Package url is here : https://docs.docker.com/engine/install/ubuntu/#install-from-a-package
After a succcesful installation I won’t be able to use docker without root access (via sudo) so their instruction is to add my user to a docker group (you should create one if none exist yet). And probably restart (for assurance) afterwards. You can copy this command to add your user to the docker group
sudo usermod -aG docker your-user-name
I also had an issue with docker daemon not running turns out /etc/docker/daemon.json was misconfigured from my previous installation. I just removed everything from the file and it ran properly.
So that’s it! In summary, next time I have to reinstall docker follow these steps :
- Install docker via packages method
- add docker group
- add my user to docker group
- restart computer
- check docker’s log if it keeps failing to launch
