*ฅ^•ﻌ•^ฅ* ✨✨  HWisnu's blog  ✨✨ о ฅ^•ﻌ•^ฅ

Docker non-Desktop on a sysVinit system [MX-Linux]

Introduction

I did a check on my disk usage and found Docker Desktop using a lot of disk space. I knew Docker can be run without Desktop, so here is my process to make it happen. Why is this post necessary? coz I'm using a sysVinit system, baby!

Every text and video tutorials you can find on the topic are for systemd, none of them is for sysVinit.

Dependencies

First you need to install some basic deps: sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Main issue

Starting the Docker Engine is not hard, it's supposed to be only run: dockerd. However in a sysVinit system you'll get this error: failed to start daemon: Devices cgroup isn't mounted

Discussion and solution were posted on this Github issue.

TLDR: you need to install cgroupfs-mount: apt-get install cgroupfs-mount. Do another test run: dockerd and this time you'll have successful log message:

Initializing buildkit
Completed buildkit initialization
Daemon has completed initialization
API listen on /var/run/docker.sock

The last line is important, take note for the next section.

Modify Docker config.json

Now do a simple Docker test run: docker run hello-world. It's throwing up error: docker: Cannot connect to the Docker daemon at unix:///home/<your_system>/.docker/desktop/docker.sock. Is the docker daemon running?

Pay attention to the Docker daemon path, it's different to the previous section:

API listen on /var/run/docker.sock

We need to make a minor modification to Docker's config.json:

sudo mkdir -p ~/.docker
cd ~/.docker
nvim config.json

Put these lines into the config.json:

{
	"auths": {
		<whatever auths you got before will be listed here>
	},
	"hosts": ["unix:///var/run/docker.sock"]
}

Note key point on the hosts field, put the correct API path. Save the file and retry: docker run hello-world
You should be receiving this in return:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
e6590344b1a5: Pull complete
Digest: sha256:7e1a4e2d11e2ac7a8c3f768d4166c2defeb09d2a750b010412b6ea13de1efb19
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

Delete docker-desktop

Lastly don't forget to remove docker-desktop: sudo apt remove docker-desktop and delete the folder at /.docker/desktop since there's a 13GB RAW file inside the desktop directory.

You might wanna re-run the hello-world container: docker run hello-world. If it runs and returns the same message log as previously then it's all good and you've successfully removed the bloated Docker Desktop while maintaining Docker usability.

IMPORTANT NOTE

Remember to activate the Docker engine when you want to work using docker containers, just use the same command: dockerd. You also can make this an autostart item on startup, but I prefer to manually launch it when I'm using it. Yes, I'm efficient like that, I don't like wasteful unnecessary processes when I don't need it.

Conclusion

This concludes this short post on using Docker non-Desktop in a sysVinit system. Trully working with sysVinit is more challenging compared to systemd since there are not a lot of tutorials availble for sysVinit system, so I hope this post helps!

I will keep on making posts for anything specific for sysVinit.