Cannot connect to the Docker daemon on macOS

前端 未结 15 1516
失恋的感觉
失恋的感觉 2020-12-07 07:23

I normally prefer to manage my apps on my OSX with brew

I am able to install docker, docker-compose and docker-machine

docker --version
Docker versio         


        
相关标签:
15条回答
  • 2020-12-07 07:38

    On macOS the docker binary is only a client and you cannot use it to run the docker daemon, because Docker daemon uses Linux-specific kernel features, therefore you can’t run Docker natively in OS X. So you have to install docker-machine in order to create VM and attach to it.

    Install docker-machine on macOS

    If you don't have docker-machine command yet, install it by using one of the following methods:

    • Using Brew command: brew install docker-machine docker.
    • Manually from Releases page:

      $ curl -L https://github.com/docker/machine/releases/download/v0.16.1/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine
      $ chmod +x /usr/local/bin/docker-machine
      

    See: Get started with Docker for Mac.

    Install Virtualbox

    docker-machine relies on VirtualBox being installed and will fail if this isn't the case. If you already have VirtualBox, you can skip this step.

    • Using Homebrew: brew cask install virtualbox
    • Manually using the releases on Virtualbox.org

    You will need to actively accept loading the Virtualbox kernel extension in the OS X Security panel and then proceed to restart the machine for the next commands not to fail with Error: VBoxNetAdpCtl: Error while adding new interface

    Configure docker-machine on macOS

    Create a default machine (if you don't have one, see: docker-machine ls):

    docker-machine create --driver virtualbox default
    

    Then set-up the environment for the Docker client:

    eval "$(docker-machine env default)"
    

    Then double-check by listing containers:

    docker ps
    

    See: Get started with Docker Machine and a local VM.


    Related:

    • Brew install docker does not include docker engine?
    • For Linux, see: Docker can't connect to docker daemon
    • For Windows, see: Docker warning: failed to get default registry endpoint from daemon
    0 讨论(0)
  • 2020-12-07 07:39

    You should execute script for install docker and launch it from command line:

    brew cask install docker
    pip3 install docker-compose
    open -a Docker
    docker-compose ... 
    

    after that docker-compose should work

    0 讨论(0)
  • 2020-12-07 07:40

    I first tried docker and docker-compose via homebrew, but it had the problem listed here. I had to install docker's official install from https://docs.docker.com/docker-for-mac/install/ and then everything worked as expected.

    0 讨论(0)
  • 2020-12-07 07:44

    I had the same problem. Docker running but couldn't access it through CLI.

    For me the problem was solved by executing "Docker Quickstart Terminal.app". This is located in the "/Applications/Docker/" folder. As long as I work in this instance of the Terminal app Docker works perfectly. If a second window is needed I have to run the "Quickstart" app once more.

    I have a Docker for Mac installation. Therefore I am not sure if my solution is valid for a Homebrew installation.

    The "Docker Quickstart Terminal" app seems to be essentially some applescripts to launch the terminal app and a bash start script that initialise all the necessary environment variables.

    Hope this helps someone else !

    0 讨论(0)
  • 2020-12-07 07:47

    i simply had to run spotlight search and execute the Docker application under /Applications folder which brew cask install created. Once this was run it asked to complete installation. I was then able to run docker ps

    0 讨论(0)
  • 2020-12-07 07:48

    on OSX assure you have launched the Docker application before issuing

    docker ps
    

    or docker build ... etc ... yes it seems strange and somewhat misleading that issuing

    docker --version
    

    gives version even though the docker daemon is not running ... ditto for those other version cmds ... I just encountered exactly the same symptoms ... this behavior on OSX is different from on linux

    0 讨论(0)
提交回复
热议问题