docker-compose is not working - docker

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.

Related

Docker desktop mac wont update docker compose

I updated docker desktop for Mac (intel) this morning to Docker Desktop 4.9.1. My docker compose version won't seem to update. When I run docker-compose --version in my terminal it returns docker-compose version 1.25.5, build unknown. I tried installing docker-compose with brew and after some tinkering I got confirmation that it installed version 2.6.0, however after restarting docker desktop and my computer, I still get 1.25.5 when I run docker-compose --version.
How can I force docker to use a newer version of docker-compose?
NOTE: In my docker-compose.yml file I have version 2 running.
My docker compose also came via Docker Desktop on MacOS and it did not update/had the latest the latest version of docker-compose. I resolved this by installing docker-compose via brew:
https://formulae.brew.sh/formula/docker-compose
brew install docker-compose
Don't forget to follow the after-install instructions:
"Compose is now a Docker plugin. For Docker to find this plugin, symlink it:"
mkdir -p ~/.docker/cli-plugins
ln -sfn /opt/homebrew/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose
The only way I was able to solve this was to completely manually uninstall docker desktop and all docker related items from brew. I deleted every docker file I could find from my lib and then reinstalled.

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

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 issues on Mac

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.

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