Docker issues on Mac - docker

I installed docker using HomeBrew on Mac.
➜ mattermost-server git:(master) docker --version
Docker version 18.09.1, build 4c52b90
➜ mattermost-server git:(master) which docker
/usr/local/bin/docker
When I run docker,
This is the error I get.
➜ mattermost-server git:(master) docker ps
Cannot connect to the Docker daemon at **unix:///var/run/docker.sock.
Is the docker daemon running?**
Update: This can be solved by removing existing docker and running
brew install cask docker
Refer here Cannot connect to the Docker daemon on macOS

I had the same problem after install docker on my mac (brew cask install docker).
docker --version works, but docker ps or any other docker command results in the error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
To solve the problem you have to :
Install Virtual Box
run : docker-machine create default to create a virtual machine (mandatory
on mac os)
run: docker-machine env default to set the environment
run: eval $(docker-machine env default)
try docker ps or docker version to check that everything is ready.

You are possibly running docker without sudo user, aren't you?
By default you should run docker with sudo user, if you don't want to do that, folow Manage Docker as a non-root user

We need to run brew cask install docker. This should fix the problem.

Related

docker compose not recognized when using sudo

My OS is Ubuntu 20.04.3 LTS.
I've installed docker compose V2, and I can access it from the command line regularly:
$ docker compose version
Docker Compose version v2.2.2
I've also installed compose-switch according to the manual instructions here: https://docs.docker.com/compose/cli-command/#compose-switch and it's working fine:
$ docker-compose version
Docker Compose version v2.2.2
But if I use sudo neither will work:
$ sudo docker compose version
docker: 'compose' is not a docker command.
See 'docker --help'
$ sudo docker-compose version
docker: 'compose' is not a docker command.
See 'docker --help'
docker version is the same with or without sudo:
Version: 20.10.12
API version: 1.41
So, how can I get docker compose working with sudo?
I had installed docker-compose under my user's home directory. I had to move the file docker-compose from ~/.docker/cli-plugins to /usr/local/lib/docker/cli-plugins
$ sudo mkdir -p /usr/local/lib/docker/cli-plugins
$ sudo mv /home/<username>/.docker/cli-plugins/docker-compose /usr/local/lib/docker/cli-plugins/docker-compose
And now everything works as expected.
The docker command you are running as your local user must be calling a different binary than what it calls when running as another user (i.e. root user).
When you invoke a command using sudo, it will by default use the root user shell environment which includes the PATH env variable.
I suspect you will see a different path output when running these two commands:
type docker
sudo type docker

can't run docker in ubuntu 20.04

I had tried to install docker like I read in lots of site with the same steps, but it didn't work and always send me that error massage:docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. and I didn't could find solution that work.
After that I tried to test a bit the sudo snap, and I was surprised to discover that I can install docker using sudo snap install docker and its look like it worked, but when I run the sudo docker run -dt centos bash, I had got the same error.
It's not only a issue with CentOS, I had tried this with kali, mint, ubuntu, and fedora, no one of them worked, and the error is always the same/
thanks for help.
You need to mount /var/run/docker.sock
sudo docker run -dt -v /var/run/docker.sock:/var/run/docker.sock centos bash

Unable to create Docker machine on Ubuntu (VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path)

I am trying to install Docker and get it up and running on my machine. But let me tell you what OS I am using and how I am using it. I have a Windows 10 laptop. Then I installed Oracle VirtualBox on it. Then I installed Ubuntu on top of it. I am trying to install Docker and get it up and running on Ubuntu. I installed Docker.
sudo snap install docker
sudo apt install docker-compose
Then I tried to boost up the Docker Compose of my project running the following command.
docker-compose up --build -d
Then I got the following error.
ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
Then I tried to create the Docker machine because there is no default machine. I run the following command.
docker-machine create -d virtualbox default
Then I got the following error.
Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"
Then I tried installing the VirtualBox running the following commands.
sudo apt-get install virtualbox
sudo apt-get install virtualbox-ext-pack
It was successfully installed. I tried running the following command again.
docker-machine create -d virtualbox default
I am still getting the same error. What is missing in my configuration and how can I fix it?

docker-compose is not working

When I am trying to test a zookeeper cluster using docker-compose, the console shows nothing.
This is my command:
COMPOSE_PROJECT_NAME=zk_test docker-compose up
No response of docker-compose command
My questions are:
I only installed docker-machine and docker-compose. The command is there, but do I need to install docker-compose additionally?
Should docker-compose be installed inside docker machine or in host machin? If the latter, how does docker-compose manage Docker containers? Because they are running inside of the Docker machine.
What I think is weird, is that when I input 'docker-compose' in the host terminal, it can be recognized by the OS (screenshot).
My environment:
OS: Mac
Docker container: docker-machine (boot2docker)
Here is how I get all necessary packages on my Mac OS machine.
Install homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then brew cask install docker
brew cask install docker
Open Docker through Applications or:
open /Applications/Docker.app
You should now how docker-compose, docker and docker-engine.

Docker client not able to connect to docker host on VM on Windows 7

I am using Docker Toolbox 1.8.2 and it is working fine on my OSX. On Windows, I have some problems.
I have created a new "default" VM (virtualbox), then connected my docker client to this docker host using "eval $(docker-machine env default)" on Cygwin. When I try to run "docker ps" from Cygwin, I get the following error:
Get http://127.0.0.1:2375/v1.20/containers/json: dial tcp 127.0.0.1:2375:
ConnectEx tcp: No connection could be made because the target machine
actively refused it..
* Are you trying to connect to a TLS-enabled daemon without TLS?
* Is your docker daemon up and running?
If I SSH into that machine and execute "docker ps", then it will return that no containers are running, meaning that the host is running.
Any ideas?
Prereqs:
Make sure you have brew installed.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
if your having troubles using brew, try uninstalling it. Then try re-installing it. To uninstall it try to use...
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Install Docker
brew install docker
Install Docker-Machine
brew install docker-machine
Create New docker Machine host - just use virtual box
docker-machine create --driver virtualbox default
Set you environment variable to see docker-machine - you should set this in your .bashrc file.
eval $(docker-machine env default)
I do not have Windows, but OS X, but in my case such error means that he cannot find route to virtual host.
In my case
sudo route -nv add -net 192.168.59 -interface vboxnet1
helps.
Change it into Windows command and try out (of course you may have to change interface name or part of IP).
Probably because docker daemon is not yet running.
On Windows, using boot2docker this is how it worked for me
make sure your VM is running, run docker-machine ls to list all VMs
boot2docker init
boot2docker start
eval "$(boot2docker shellinit)"

Resources