bash docker command not found in centos7 after installing docker - docker

I installed docker in centos7 and started docker service.
I checked docker service it is running. But when I run docker --version getting error like bash docker command not found. Why?

Add "C:\Program Files\Docker Toolbox" into my path environment

Related

Docker - unknown command "run"

I am trying to run a docker container on an Ubuntu WSL2 instance on Windows 10. Docker version installed in 20.10.17. I have been able to run docker commands and build the image successfully.
The output of docker images:
When I try to run the container using the command docker run -p 5000:5000 test it gives the following error:
I have never had this issue with docker before and not sure why it thinks it's an npm command. Does anyone know why this is happening?

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

Docker on Ubuntu inside WSL

I want to play with hyperledger fabric and this require to have linux.
Right now I want to use Windows and my idea was to install Ubuntu with WSL and just develop inside it.
The problem apear when I want to use docker.
I follow the steps in this tutorial step by step but I run into some problem.
filip#CSGN044D:~$ docker --version
Docker version 19.03.5, build 633a0ea838
filip#CSGN044D:~$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
filip#CSGN044D:~$ sudo service docker start
* Starting Docker: docker
and again...
filip#CSGN044D:~$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
Is this even possible ?
Looks like your Docker CLI is still trying to connect to the local Unix socket instead of localhost. Make sure your DOCKER_HOST environment variable is set to tcp://localhost:2375
Try by setting it in your shell first
export DOCKER_HOST=tcp://localhost:2375
Sanity check
echo $DOCKER_HOST
Now try running all your regular Docker commands. If those work, add this to your .bashrc
echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc
source ~/.bashrc
Not that in the tutorial the author uses localhost:2375 instead of tcp://localhost:2375. I think you have to explicitly specify the protocol. Also, your shell might not be using bash_profile as the config file (Usually Mac shells use that) so try adding it to your bashrc instead.

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.

Boot2Docker starting Ubuntu image

I am trying to get the latest Ubuntu image going om my Windows 7/Boot2Docker machine but when i try to start the image i get an error message.
exec: "C:/Program Files (x86)/Git/bin/bash": stat C:/Program Files (x86)/Git/bin/bash: no such file or directory
Full errormessage:
$ docker run -t -i ubuntu /bin/bash
exec: "C:/Program Files (x86)/Git/bin/bash": stat C:/Program Files (x86)/Git/bin/bash: no such file or directory
FATA[0000] Error response from daemon: Cannot start container 100e77a5ac95f8fb8dc55e6382e7a8cd6f946ec807e90d9efdb6fc905a046569: [8] System error: exec: "C:/Program Files (x86)/Git/bin/bash": stat C:/P
rogram Files (x86)/Git/bin/bash: no such file or directory
Any clue on how to work around this? Another image like the default Jenkins one works ok!
The Ubuntu image is pulled correctly
Running Ubuntu image after SSH:
docker#boot2docker:~$ docker run ubuntu
docker#boot2docker:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
It means that somehow your $PATH (within the boot2docker session) includes "C:/Program Files (x86)/Git/bin/" before /bin.
Check the $PATH you have when running docker run --rm -it ubuntu:latest.
The fact that you manage to run the image in a boot2docker ssh session, but docker ps displays nothing seems expected.
Only a docker run --rm -it ubuntu would display a shell.
A simplt docker run would exit the shell immadiatly (non-interactive run), and the container would be in status 'Exited' (see docker ps -a output)
First of all, before you create a container, you have to run "Boot2Docker Start" to start docker virtual machine then start your container inside docker VM. follow up the instructions in this link https://docs.docker.com/installation/windows/
Second, I think that it is preferred to install docker over linux machine not windows, you will get all capabilities of docker.
Best Regards,
Ahmed

Resources