Couldn't Connect to Docker Daemon on Mac - docker

Using the newest version of Docker as of August 25, 2017, I know that Docker no longer requires a VirtualBox setup along with boot2docker to work. However, in trying to connect to it and use docker-compose, I am unable to connect to docker. My compose file works as when I install all necessary prerequisites using homebrew (and therefore use docker-machine), everything is fine. The error message is as follows:
Couldn't connect to Docker daemon. You might need to start Docker for Mac.
I have since done the following to no avail:
remove ~/.docker folder
restart docker through the app
restart the docker app itself
open a new terminal session

It turns out I had some old docker environment variables in my ~/.bash_profile that docker-compose was reading and trying to connect to docker-machine, as a result. After commenting out the following from my ~/.bash_profile:
export DOCKER_CERT_PATH=/Users/williamrwatson/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://192.168.59.103:2376
I was good to go:
Creating network "docker_default" with the default driver
Creating docker_redis_1 ...
Creating docker_redis_1 ... done

Related

Symfony CLI doesn't export docker desktop vars

I'm on mac (Apple chip), and I'm trying to create a Symfony project using Symfony CLI & Docker.
$ symfony create new_project
$ cd new_project
$ symfony composer require orm
It install Symfony, Doctrine, and ask me to create docker-compose.yml.
Perfect.
I can even launch docker-compose up --build and I can see the container being build & launched on my Docker Desktop application.
But when I launch my symfony server, I'm unable to connect to the database.
As I read, I try the command symfony var:export -vv and then, I can see than none of the docker variables are automatically exported. And I can see, thanks to the -vv option, this silent error :
WARNING symfony Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I looked at this error and I try docker-machine ls. I can see that there is no docker-machine working on my computer, even if my Docker Desktop says otherwhise.
How can I make Docker Desktop & Symfony CLI works together ? Why docker-image and Docker Desktop doesn't communicate ?
When I look to the Docker Desktop documentation, they mention that the Docker Desktop provide the docker API through unix:///var/run/docker.sock but mine seams not working.
Thank you for your help :)
docker-machine is a legacy software for OSX. Uninstall it and install the latest version of docker using the command brew install --cask docker and then try the same steps as before.

Sharing docker credentials between Window and WSL

Environment
Windows version and build Version 2004 (OS Build 19037.1)
Docker Edge version 2.1.6.1
Ubuntu 18.04 on WSL 2
Current setup and status:
docker installed on windows
created aliases for docker, docker-compose, docker-credential-desktop, etc ...
Running commands such as docker build, docker ps, docker pull, docker images all work fine. Now I would like push an image and so of course I have to login first.
Problem: logging into docker hub.
I run docker login in the WSL terminal
I put in my username and password
I get the following error
Error saving credentials: error storing credentials - err: exec: "docker-credential-desktop": executable file not found in %PATH
%, out: ``
What I've tried so far
docker login from powershell works fine. So I created a symbolic link between /mnt/c/Users/<winusername>/.docker and /home/<wslusername>/.docker. The equivalent works fine for .aws, but for .docker it was not able to share or even acknowledge the credentials, so it asked again for the user and password and threw the same error as above.
This worked for me,
sudo ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker-credential-desktop.exe /usr/bin/docker-credential-desktop.exe
Linking the executable from windows path to linux path or you can add the windows PATH on you linux PATH.
Refer: https://github.com/docker/for-win/issues/6652
Update Feb 2021
This is all much simpler now. If you are using WSL2 on a recent release of Windows, just install docker on the Windows side and ensure to configurations:
In General: us the WSL 2 based engine
In Resource/WSL Integration: enable integration with your default WSL distro
You will have to restart docker. Once it is done, everything works transparently.
Below here can be ignored
It turns out that the integration between Docker and WSL is better than I thought. Though it could have been better documented. I was going to change tack and try to install docker in the WSL. So I got rid of all the aliases and restarted my session. Lo and behold, when I ran docker there was still something running.
This is because the edge version of docker create the appropriate symbolic links and now I login into docker hub without any problem.

Docker Toolbox setup fails on Windows 8.1

After (successfully, I believe) installing the Docker Toolbox, I get the following error:
$ docker ps
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.26/containers/json: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
Also, when I try to run the docker quickstart terminal, it just prints the following error:
Docker Machine is not installed. Please re-run the Toolbox Installer and try aga
in.
Looks like something went wrong in step 'Looking for vboxmanage.exe'... Press an
y key to continue...
I searched through the docker troubleshooting but didn't find any hint.
I tried installing the toolbox both with and without checking the "Install VirtualBox with NDIS5 driver [default NDIS6]" checkbox.
Try this,
Check if the docker machine exists. Command to check this below.
docker-machine ls
If you still get error then execute step 2 below. If you see any machine listed and it has STATE stopped then execute docker-machine start machine_name eg. docker-machine start default
This step helps you to create a docker-machine.
docker-machine create --driver virtualbox default
I also face some problems like you and I troubleshoot the problem with the following steps in window 8.1.
Install Docker Toolbox
REGENERATE CERTIFICATES
$ docker-machine regenerate-certs default
Regenerate TLS machine certs? Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Create new machine default
$ docker-machine create default
Note: It may take a few minutes for downloading boot2docker.iso file.
UPGRADE docker-machine (Optional)
$ docker-machine upgrade
START Docker Quickstart Terminal (or) Run start.sh file under the location => C:\Program Files\Docker Toolbox
RUN HELLOWORLD
$ docker run hello-world
I hope it will help you :-)

Error in Docker: bad address to executables

I'm trying to something with Docker.
Steps I'm doing:
- Launch Docker Quickstart Terminal
- run docker run hello-world
Then I get error like:
bash: /c/Program Files/Docker Toolbox/docker: Bad address
I have to say that I was able to run hello-world image, but now I'm not. I don't know what happend.
I don't know if it matters however I had some problems at instalation step.
Since I have git installed in non standard location. However it seems git bash.exe working correctly for Docker.
My environment:
Windows 10
Git 2.5.0 (installed before Docker)
Docker Toolbox 1.9.1a
I have the same issue with bash: /c/Program Files/Docker Toolbox/docker: Bad address
I thought the problems is "bash doesn't support docker.exe".
SO I fix this problem by use powershell ,not the bash.
and if you use powershell maybe face this
An error occurred trying to connect: Get http://localhost:2375/v1.21/containers/json: dial tcp 127.0.0.1:2375: ConnectExenter code here
tcp: No connection could be made because the target machine actively refused it.
You can export variable from bash use export and import to powershell by this below
$env:DOCKER_HOST="tcp://192.168.99.100:2376"
$env:DOCKER_MACHINE_NAME="default"
$env:DOCKER_TLS_VERIFY="1"
$env:DOCKER_TOOLBOX_INSTALL_PATH="C:\\Program Files\\Docker Toolbox"
$env:DOCKER_CERT_PATH="C:\\Users\\kk580\\.docker\\machine\\machines\\default"
that's all
ps:I found this problem fixed by update git from 2.5.0 to 2.6.3.
Not entirely sure what the issue is, report it to the project on github. I find the docker mac and windows tools a bit flakey from time to time as they are still maturing. If you don't mind seeing what's underneath, you can try running docker-machine directly or set up your own host pretty quickly with Vagrant.
Docker Machine
Run a command or bash prompt to see what machines you have.
docker-machine ls
Create a machine if you don't have one listed
docker-machine create -d "virtualbox" default-docker
Then connect to the listed machine (or default-docker)
docker-machine ssh default-docker
Vagrant
If that doesn't work you can always use vagrant to manage VM's
Install VirtualBox (Which you probably have already if you installed the toolbox)
Reinstall Git, make sure you select the option for adding ALL the tools to your system PATH (for vagrant ssh)
Install Vagrant
Run a command or bash prompt
mkdir docker
cd docker
vagrant init debian/jessie64
vagrant up --provider virtualbox
Then to connect to your docker host you can run (from the same docker directory you created above)
vagrant ssh
Now your on the docker host, Install the latest docker the first time
curl https://get.docker.com/ | sudo sh
Docker
Now you have either a vagrant or docker-machine host up, you can docker away after that.
sudo docker run -ti busybox bash
You could also use PuTTY to connect to vagrant machines instead of installing git/ssh and running vagrant ssh. It provides a nicer shell experience but it requires some manual setup of the ssh connections.

docker-machine install fails due to 'Couldn't read CA cert' error

I am trying to setup docker-machine locally on my Windows machine and I followed the install instructions at the Docker Machine Page.
Per the instructions, I ran the following commands in my bash terminal
To install Docker client binary
$curl -L https://github.com/docker/machine/releases/download/v0.3.0/docker-machine_windows-amd64.exe > /bin/docker-machine
and to install Docker machine binary
$ curl -L https://github.com/docker/machine/releases/download/v0.3.0/docker-machine_windows-amd64.exe > /bin/docker-machine
when I try to run docker-machine -v I get the following error
FATAL[0000] Couldn't read ca cert 'C:\Users\Me\.boot2docker\certs\boot2doker-vm\ca.pm: open 'C:\Users\Me\.boot2docker\certs\boot2docker-vm'\ca.pem: The filename, directory name, or volume label syntax is incorrect.
I did some searching and came across a few posts, but can't really see any connection to what would be causing my issues...
https://github.com/hypriot/kitematic/pull/1
https://github.com/docker/machine/issues/908
I installed docker machine today on my Windows 7 machine and run the command without any problem.
Did you use boot2docker before on your machine? If you did, it might be related as mine is a clean machine without any pre-existing docker installations.
Its referring to boot2docker environment.
see this:
DOCKER_CERT_PATH="/Users//.docker/machine/machines/dev"
I got the same answer and was able to resolve it by changing the path pattern to be unix-style in the environment variable.
Inside msysgit bash shell:
export DOCKER_CERT_PATH=/C/Users/Me/.boot2docker/certs/boot2docker-vm
This resolved boot2docker.
Note that I also tried using docker-machine before using boot2docker which previously failed with the same error. That was not resolved the same way boot2docker could be resolved. For now only boot2docker is working for me.

Resources