Other possible titles for this post
âRTFM, oh boyâŠâ
Buy a new laptopâŠ
Saving Private Ryan, where are you daemon.json?
I need to reconsider the use of Docker on my Mac M1 Pro. With a small disk and 1000 programs đ , everything is fine at least until I start Docker Desktop. I use a lot of images and experiments that I never finish because Iâm a lazy person. I was looking for some solution because my machine is crying all the time, and I feel like a loser deleting files, running docker system prune, and deleting my 1 million node modules from unfinished projectsâŠ
I have an old machine that I just use to do some experiments or run Windows for specific tasks or problems. That machine has Ubuntu and Windows as a dual boot. Yes, itâs a Frankenstein, and I feel nostalgic about Ubuntu.
â Sheldon: âOh, Ubuntu!â
Ok, give me the đ© solution.
I installed Docker on Ubuntu, allowed remote connection, and overrode the Docker client host to point to my old machine, and voila!
Or at least, I thought it was really easy to do. I checked the internet and ChatGPT told me to edit /etc/docker/daemon.json on my Ubuntu machine and just put:
{
"hosts": [
"unix:///var/run/docker.sock",
"tcp://0.0.0.0:2376"
]
}
Easy peasyâŠ
No, that broke my Docker on Ubuntu (24.04 LTS).
After a couple of hours and going through a lot of tutorials, I found the documentation!! (Yes, RTFM) https://docs.docker.com/config/daemon/remote-access/ and finally understood why I couldnât find the file. It was a misunderstanding of how Docker runs on the OS and the changes of Ubuntu to systemd.
For systemd we need to edit the service with sudo systemctl edit docker.service
, as the documentation said, but, oh surprise, it didnât work for meâŠ
So, what happened was I needed to edit the service file directly:
sudo nano /lib/systemd/system/docker.service
And I commented out the lines containing ExecStart below [Service], and added these lines:
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375
I restarted the service with:
sudo systemctl daemon-reload
sudo systemctl restart docker.service
You need to confirm if port 2375 is accessible on your local network (this is another story; on my machine, it was available by default).
For now, thatâs all on Ubuntu. Now, on the Mac, Docker doesnât start on login, so when I run docker ps on the terminal, youâll see:
docker ps
Cannot connect to the Docker daemon at unix:///Users/your_user/.docker/run/docker.sock. Is the docker daemon running?
And thatâs ok. Now for the magic:
export DOCKER_HOST=tcp://<UBUNTU_LOCAL_IP>:2375
Where UBUNTU_LOCAL_IP is the IP of your Ubuntu machine on the same network. Now, if you are on the same network:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
And thatâs it! Enjoy! đ
Please consider the security consequences of using this over your local network.
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.