Mac OS X sudo docker Cannot connect to the Docker

2020-02-17 10:00发布

I installed docker and there seems to be some issue.

$ docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

$sudo docker ps

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

What should I do?

标签: macos docker
6条回答
倾城 Initia
2楼-- · 2020-02-17 10:46

to have it persistent on new terminals & reboot put it to the bash_profile file

echo "eval \$(docker-machine env default)" >> ~/.bash_profile
查看更多
啃猪蹄的小仙女
3楼-- · 2020-02-17 10:51

You need to set up your shell to use Docker: eval $(docker-machine env default) Where does this command come from? Run docker-machine env default and you'll see something like the following:

$ docker-machine env default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/eric/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell: 
# eval $(docker-machine env default)

Also you may or may not have to simply start the Docker host beforehand via: docker-machine start default

查看更多
一夜七次
4楼-- · 2020-02-17 10:55

I had this same issue I solved it in the following steps:

docker-machine restart

Quit terminal (or iTerm2, etc, etc) and restart

eval $(docker-machine env default)
查看更多
The star\"
5楼-- · 2020-02-17 10:56

if you are using docker toolbox, type this before running the docker ps command to set the environment

docker-machine env default
查看更多
做自己的国王
6楼-- · 2020-02-17 10:58

docker-machine is a legacy stuff for OSX that operates with VirtualBox. What you should do is get rid of it completely, and then you should download the latest version of docker, that is called Docker for Mac

Make sure, you remove the legacy docker, and the docker-machine from your Mac before installing Docker for Mac. If you do not do that, the legacy docker binary will be favoured after the installation, and you will still get the error message, which says that cannot connect to the Docker daemon.

查看更多
何必那么认真
7楼-- · 2020-02-17 10:58

I just had this problem. I was using the old docker-machine and I switched to the latest docker for mac. Running eval $(docker-machine env default) sets up some environment variables.

To solve my problem, I unset those environment variables...

unset DOCKER_HOST DOCKER_MACHINE_NAME DOCKER_TLS_VERIFY DOCKER_CERT_PATH

查看更多
登录 后发表回答