[Fixed] Error while Building Docker Container using linux command on MacOS – "must use ASL logging (which requires CGO) if running as root" – Docker

by
Ali Hasan
boot2docker macos

Quick Fix: Modify the Docker daemon to run as a non-root user by using the following command:

sudo usermod -aG docker $USER

Then log out and log back in to apply the changes.

The Problem:

When attempting to build a Docker container on macOS using the ‘sudo docker-compose up –build’ command, the process fails with the error message ‘must use ASL logging (which requires CGO) if running as root’.

The Solutions:

Solution 1: Run Docker Daemon as Non-Root User

When using Docker Desktop on macOS (Apple Silicon), it’s recommended to run the Docker daemon as a non-root user. This avoids any issues with root-level permissions.

To run Docker as a non-root user, simply remove the sudo prefix from the docker-compose command:

docker-compose up --build

If prompted, enter your computer password to grant the necessary permissions.

Q&A

Which user should docker be run as?

Run the Docker daemon as a non-root user.

Where can I learn more about running Docker as non-root?

Refer to: [Run the Docker daemon as a non-root user (Rootless mode)][1]

Video Explanation:

The following video, titled "0 to LSP : Neovim RC From Scratch - YouTube", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

Comments1.9K. A K. Wait wait, let me get my popcorn, blanket and laptop.