Can't run docker on os X with boot2docker - macos

I've tried to remove docker with this manual.
And I removed virtualbox. And then tried to install boot2docker.
After boot2docker init etc (by the manual on docker site)
docker run helloworld
gives me this error
Cannot connect to the Docker daemon. Is 'docker -d' running on this
host?
boot2docker status
running
docker version
Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): darwin/amd64
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

You need to run boot2docker up then docker run helloworld.

Boot2docker is not the recommended way of using Docker (on Windows/OS X) anymore (IMHO).
See Docker Machine instead (which can use the "boot2docker iso" internally, but not only).
You may also want to import your existing boot2docker environment (to keep your built images, etc.), it's possible too.
Then using Docker Machine, you can create a working Docker environment with the following commands:
On OS X (or an OS which supports eval and export commands), if you have the Docker CLI installed:
docker-machine create -d virtualbox dev
eval "$(docker-machine env dev)"
docker run hello-world
OR
On any OS, if you have not the Docker CLI installed:
docker-machine create -d virtualbox dev
docker-machine ssh dev
docker run hello-world

Maybe the daemon is not running?
Damiens-MacBook-Air:tmp damien$ docker version
Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): darwin/amd64
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
... check if the daemon is running :
Damiens-MacBook-Air:tmp damien$ boot2docker ssh sudo /etc/init.d/docker status
Docker daemon is not running
error in run: exit status 1
then start it :
Damiens-MacBook-Air:tmp damien$ boot2docker ssh sudo /etc/init.d/docker start
Need TLS certs for boot2docker,127.0.0.1,10.0.2.15,192.168.59.103
-------------------
and now you should be able to connect.
Damiens-MacBook-Air:tmp damien$ docker version
Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): darwin/amd64
Server version: 1.7.0
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 0baf609
OS/Arch (server): linux/amd64

Related

docker: command not found in bash script but can use docker in bash

I'm using bash on windows server 2019, and trying to run a simple bash script, but when it gets to this line:
# check if containers are running, and stop them if they are not for the current project
all_up_ids=$(docker ps -q);
I get a 'docker docker command not found' error. Oddly I can run docker and docker-compose in bash no problem. I have set my environment variables. The only way I was able to get docker commands to work in bash was to put this in my .bashrc file
export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
export PATH="$PATH:/mnt/c/Program\ Files/Docker/Docker/resources/bin"
alias docker=docker.exe
alias docker-compose=docker-compose.exe
Is it possible something is still wrong with my environment setup? Any assistance is appreciated.
Docker Info:
Client: Docker Engine - Enterprise
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 2ee0c57608
Built: 11/13/2019 08:00:16
OS/Arch: windows/amd64
Experimental: true
Server: Docker Engine - Enterprise
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.24)
Go version: go1.12.12
Git commit: 2ee0c57608
Built: 11/13/2019 07:58:51
OS/Arch: windows/amd64
Experimental: true
The ~/.bashrc script is being executed only for interactive terminals, that means every time you open a terminal window, ~/.bashrc gets executed in that session. So anything defined there won't be available for scripts, because they're being executed in a non-interactive mode.
I would rather put your configuration into ~/.bash_profile. That script gets executed only once when you open a login shell, so when you log in and start a script, it will be available for that script also.
It's not directly related (not Ubuntu), but has the same error message
Just in case ...on RHEL docker can be installed as podman-docker:
sudo dnf install podman-docker

How I can I get HOST_IP for Docker using docker-machine?

I just got a new Mac. My old Mac had a shell script that included these lines:
ACTIVE=`docker-machine active 2>/dev/null`
HOST_IP=`docker-machine ip $ACTIVE`
When I run this on the new machine it doesn't work. Just running the docker-machine active command independently I get output like this:
No active host found
I figured I try to create a default with docker-machine create default, but got this:
dial-http tcp 127.0.0.1:49719: unexpected EOF
I'm not sure what version of Docker my old Mac was running, but it was native. New Mac:
Client:
Version: 17.06.1-ce
API version: 1.30
Go version: go1.8.3
Git commit: 874a737
Built: Thu Aug 17 22:53:38 2017
OS/Arch: darwin/amd64
Server:
Version: 17.06.1-ce
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: 874a737
Built: Thu Aug 17 22:54:55 2017
OS/Arch: linux/amd64
Experimental: true
New versions of Docker for Mac no longer user VirtualBox and docker-machine. It's running on xhyve and you can run docker commands very similar to if you were running docker natively on a linux host. There's still a VM under the covers (using moby), but your scripts shouldn't see that anymore. Anything you use to connect to published ports can now connect to localhost as if it is running directly on the Mac host.

Brew install docker does not include docker engine?

Trying to setup docker from brew, however the engine does not seem to be included in any of the any of the official formulas.
brew install docker-machine docker-compose
So these only installs the clients?
Is there no keg with the engine/daemon?
The following steps work fine on macOS Sierra 10.12.4. Note that after brew installs Docker, the docker command (symbolic link) is not available at /usr/local/bin. Running the Docker app for the first time creates this symbolic link. See the detailed steps below.
Install Docker.
brew install --cask docker
Launch Docker.
Press ⌘ + Space to bring up Spotlight Search and enter Docker to launch Docker.
In the Docker needs privileged access dialog box, click OK.
Enter password and click OK.
When Docker is launched in this manner, a Docker whale icon appears in the status menu. As soon as the whale icon appears, the symbolic links for docker, docker-compose, docker-credential-osxkeychain and docker-machine are created in /usr/local/bin.
$ ls -l /usr/local/bin/docker*
lrwxr-xr-x 1 susam domain Users 67 Apr 12 14:14 /usr/local/bin/docker -> /Users/susam/Library/Group Containers/group.com.docker/bin/docker
lrwxr-xr-x 1 susam domain Users 75 Apr 12 14:14 /usr/local/bin/docker-compose -> /Users/susam/Library/Group Containers/group.com.docker/bin/docker-compose
lrwxr-xr-x 1 susam domain Users 90 Apr 12 14:14 /usr/local/bin/docker-credential-osxkeychain -> /Users/susam/Library/Group Containers/group.com.docker/bin/docker-credential-osxkeychain
lrwxr-xr-x 1 susam domain Users 75 Apr 12 14:14 /usr/local/bin/docker-machine -> /Users/susam/Library/Group Containers/group.com.docker/bin/docker-machine
Click on the docker whale icon in the status menu and wait for it to show Docker is running.
Test that docker works fine.
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
$ docker version
Client:
Version: 17.03.1-ce
API version: 1.27
Go version: go1.7.5
Git commit: c6d412e
Built: Tue Mar 28 00:40:02 2017
OS/Arch: darwin/amd64
Server:
Version: 17.03.1-ce
API version: 1.27 (minimum version 1.12)
Go version: go1.7.5
Git commit: c6d412e
Built: Fri Mar 24 00:00:50 2017
OS/Arch: linux/amd64
Experimental: true
Please try running
brew install docker
This will install the Docker engine, which will require Docker-Machine (+ VirtualBox) to run on the Mac.
If you want to install the newer Docker for Mac, which does not require virtualbox, you can install that through Homebrew's Cask:
brew install --cask docker
open /Applications/Docker.app
To install Docker for Mac with homebrew:
brew install homebrew/cask/docker
To install the command line completion:
brew install bash-completion
brew install docker-completion
brew install docker-compose-completion
brew install docker-machine-completion
Docker desktop will not be installed if you run brew install docker. If you've already installed it this way, first uninstall with brew uninstall docker.
To install Docker Desktop, run:
brew install homebrew/cask/docker
Launch docker from your /Applications folder once and enter your password, then you can run commands like docker --version to verify the CLI is working.
Docker Desktop for Mac is not a suitable choice for enterprise docker users as it requires a paid license to use. Rancher Desktop is a viable open-source alternative for Docker Desktop for all three major OS.
Since this question is specifically targeted at Mac OS users, I have added the steps to make it work on Mac OS.
First install Docker using homebrew.
brew install docker
Install Rancher Desktop.
In Kubernates Settings, change container runtime to dockerd.
Profit !
UPDATE: There's another open-source container runtime in the scene, named Colima (https://github.com/abiosoft/colima).
For reinstall docker, you should run:
brew reinstall homebrew/cask/docker

Kitematic Fail after clean setup

I've just install Docker on Mac OS 10.10.5 and ran Kitematic after that and got a hug error right away. This is the beginning of it, I can paste the rest if it will help
Command failed: /usr/local/bin/docker-machine -D start default,Docker
Machine Version: 0.7.0, build a650a40,Found binary path at
/usr/local/bin/docker-machine,Launching plugin server for driver
virtualbox,Plugin server listening at address 127.0.0.1:62284,()
Calling .GetVersion,Using API Version 1,() Calling .SetConfigRaw,()
Calling .GetMachineName,command=start machine=default,(default)
Calling .GetState,(default) DBG | COMMAND: /usr/local/bin/VBoxManage
showvminfo default --machinereadable,(default) DBG | STDOUT:,(default)
DBG
$ docker version
Client:
Version: 1.11.1
API version: 1.23
Go version: go1.5.4
Git commit: 5604cbe
Built: Tue Apr 26 23:44:17 2016
OS/Arch: darwin/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
$ docker info
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Stopped Unknown
I've read the Get started with Docker Machine and a local VM one more time and found I need to run eval "$(docker-machine env default)" to setup the env-var for docker on Mac OS X.

Docker daemon does not start or restart

I am on ubuntu 14.04 and I also upgrade docker to recent version.
Whenever I do a sudo /etc/init.d/docker start I get a successful pid as follows,
docker start/running, process 16267
When I view the PID details, I see nothing -
ps -p 16267
PID TTY TIME CMD
And when I try to do a sudo docker version I see the below -
Client API version: 1.16
Go version (client): go1.2.1
OS/Arch (client): linux/amd64
2015/01/10 10:30:49 Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
The output of sudo docker -d is as follows,
[2015-01-12T21:05:59.889680188+08:00] [info] docker daemon: ; execdriver: native; graphdriver:
[2015-01-12T21:05:59.889800519+08:00] [83736c52] +job serveapi(unix:///var/run/docker.sock)
[2015-01-12T21:05:59.895688816+08:00] [info] Listening for HTTP on unix (/var/run/docker.sock)
[2015-01-12T21:05:59.904409095+08:00] [83736c52] +job init_networkdriver()
[2015-01-12T21:05:59.932947471+08:00] [83736c52] -job init_networkdriver() = OK (0)
[2015-01-12T21:05:59.933137366+08:00] [fatal] log.go:64 Could not locate dockerinit: This usually means docker was built incorrectly. See http://docs.docker.com/contributing/devenvironment for official build instructions.
I am not sure what is going wrong. Has anyone overcome similar issues? I am not even sure when I should check for more logs on this. Any directions on this will be helpful.
Thanks
You probably have a corrupted install.
Uninstall docker
Make sure you don't have a dockerinit (updatedb / locate dockerinit) -> delete it
Reinstall docker
This should do the trick.
If not, try uninstalling docker again and try with binaries from https://docs.docker.com/installation/binaries/.

Resources