Reputation: 182
Problem description: Each time I start any CLI on my Mac, a message appears multiple times in it: "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"
The message appears only if the Docker application is not running. The Docker software basically works on my machine, so there is no need to fix it: When I start the Docker application manually, the message is not shown; as expected.
Desired solution: I just want to get rid of the message. Is there any way to fix or suppress it; like remove it from some autostart file or folder?
Why? - I prefer to start Docker manually when I need it; in order to save system resources and reduce battery usage.
My setup:
Tested CLIs:
Previous research:
Upvotes: 0
Views: 721
Reputation: 381
I had it too. It was due to a command in my .bash_profile
:
alias killimages="docker kill $(docker ps -q)"
at the start Bash seems to run docker if something like this is in an alias. Didn't know that.
Upvotes: 0
Reputation: 122
I had the same issue. I think, this is a very generic problem and surprisingly hardly anyone of the posts like this on stack-overflow has answered the issue. Below is my finding :
Boom. Finally my problem Solved :-)
Upvotes: 1
Reputation: 182
I found a solution and that there are different possible issues.
The file .bash_aliases in the User folder contains aliases for Docker commands. These are read and run (?) each time the CLI starts.
Wrapping the aliases with a silenced check did the trick for me on MacOS. This will remove any CLI error message from aliases being not available.
docker_code=$(docker ps &>/dev/null)
docker_status=$?
# echo "Docker status: $docker_status"
if [ "$docker_status" == "0" ]; then
# OK: Docker has started and is fully running
alias dcu="docker-compose up"
alias dcd="docker-compose down"
alias dcb="docker-compose build"
fi
# else = FAIL: Docker is not available, not running or shutting down
This might not make sense for everyone, as aliases are sometimes not available.
# Reload Bash config
alias rcfg="source ~/.bashrc"
The above solution is based on these articles:
Upvotes: 2