macOS and Docker

I don’t know how is it about you, but in my case, I have already faced the total lag of the system due to having / consumed 100% by Docker.

At the time of writing, I have made two things to save my Macintosh HD. First, push your
com.docker.docker out of your system HDD.

~/Library/Containers/com.docker.docker -> /Volumes/docker/Users/$USER/Library/Containers/com.docker.docker

Second. Make sure to set data-root such way it points at external drive as well.

{
  "builder": {
    "features": {
      "buildkit": true
    },
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "data-root": "/Volumes/docker/Users/$USER/Library/Containers/com.docker.data-root",
  "experimental": false
}

.

.

Third. Make sure to avoid backing up your Docker data by Time Machine. You can read about that here.

Update

It doesn’t work as expected :( It turned out that data-root doesn’t work as expected on macOS. If I use it, I am getting errors like this

ERROR: failed to solve: failed to register layer: open /root/.bash_logout: operation not permitted

Funny thing is, that using symbolic links works as expected.