Couldn't connect to Docker daemon on ubuntu - docker

I am using docker-compose-version 1.7.0,
Not using docker machine:
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
it all worked perfectly for weeks...
Now when i try running
docker-compose up
i get this error:
Couldn't connect to Docker daemon-you might need to run docker-machine start default.
I cant figure out what happened, any ideas?

Run it with sudo.
Its bad to run docker with sudo so you should add your user to the docker group
https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo

Related

Node-container is unable to connect to MariaDB-container on Ubuntu 21.04

I just set up an Ubuntu 21.04 Droplet on Digital Ocean and installed Docker according to Docker's documentation. I then installed docker-compose using sudo apt install docker-compose.
I then tried to launch my containers, a linuxserver/mariadb container called mariadb and a Node-app I've written myself which tries to connect to it. I was met with ENOTFOUND 'mariadb' errors and similiar errors. I tried to specify the IP-adress that lead to the MariaDB-container but no luck.
I could ping the MariaDB-container from bash (running docker exec -it [my node container] /bin/sh with no issues.
The solution was to uninstall (sudo apt remove docker-compose) and follow the official Docker documentation.
After doing that my Node-container can finally resolve the hostname and connect to it.

docker installation in ubuntu and start problem

I'm unable to start docker service in ubuntu 18.04.
How do I install docker, and how do I start the start docker service?
When running systemctl start docker I got this error:
System has not been booted with systemd as init system (PID 1). Can't operate.
This is the error related to Ubuntu Linux service error, not by Docker
You Can Use
sudo service docker start/status/stop instead of systemctl
Instead, use: sudo service docker start
Docker doesn't require any explicit commands to start its service.
Kindly use steps shared in below like for Setting up docker in Debian i.e Linux machine
https://docs.docker.com/engine/install/debian/
you can get rid of using sudo for every command by doing this Manage Docker as a non-root user

Install a package with Docker in Ubuntu

I want to install a package by docker, following instruction in: https://dynamic-fba.readthedocs.io/en/latest/installation.html#installing-from-source
I installed ubuntu and then Docker. But I don't understand what I need to do next. There it is said to type (docker run -it -v ${PWD}:/opt/examples davidtourigny/dfba python3 examples/example1.py). I excatly type it in ubuntu but I get this error:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
Using alternative method of dockerfile, I also get error. I don't know how to make use of make build, but used build instead following tutorials on the web.
It's my first time using Docker and I don't know what to do.
Any help is very appreciated.
The Docker application has two components, a back-end server, and a front-end cli. This way you can do cool stuff like control Docker remotely or have orchestration frameworks that manage multiple Docker nodes over the network like Kubernates.
For security, the Docker back-end server is not exposed on a normal TCP port but it uses a unix domain socket (Linux magic that makes a file act as a port) at unix:///var/run/docker.sock.
When you execute docker run -it ... the cli application will attempt to connect to the backend server, but it looks like the daemon/server is probably not running.
Try to check that daemon is running. If you are using systemd you can check with
systemctl status docker and start if is stopped with systemctl start docker finally it might be good to enable it to make sure it starts automatically on reboot, you can do that with systemctl enable docker
Make sure to start docker service (you can either go for systemctl start docker or reboot your computer).
Once this is done, it is likely that your user has no permissions to communicate with Docker without sudo. Docker has privileged access to your hardware and therefore giving a user the docker group is required for security reasons.
Run:
sudo usermod -aG docker $USER
groupadd docker
docker run hello-world
This will add you to docker group, reflect the changes inmediately and run a sample image from Docker.
If all was okay, the last command should tell you "Hello from Docker".

Why docker-daemon is not accessible in minikube VM?

I have installed minikube and started it with it's default virtual machine so basically started the minikube with minikube start. In minikube vm which i have accessed through minikube ssh i am trying to build my dockerfile after mounting the local file system but it's showing error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I checked the ActiveState of docker through systemctl show --property ActiveState docker and it's showing failed but the docker version is showing me all the normal details like version built etc.
This is the statement that i am trying to execute : $ sudo docker build --file=Dockerfile --tag=demo-backend:latest --rm=true .
Should i install docker seperatley and if not how should access docker in VM which is already present in my system
It looks like somehow docker has not started properly.
Please try to execute sudo systemctl start docker and let me know if that was the issue.
EDIT:
Adding more info from the comments in order to supplement the answer:
I had to set the docker environment variable to local instance of
docker running in minikube through this command: eval $(minikube
docker-env) and then restart the docker and all of this has to done in
the same shell in which i aim to access the docker otherwise it does
not works. this made me acces the docker from minikube – rehan

Docker can connect to engine, but docker compose cannot

I'm running Docker from within a container, which I start like so:
docker run -d `
-v //./pipe/docker_engine://./pipe/docker_engine `
-v "$($dockerpath):C:/docker"
From within the container, I can run docker ps just fine and it returns the running containers on the host engine.
However, when I run docker-compose, I get the error:
Couldn't connect to Docker daemon. You might need to start Docker for Windows.
This worked fine back when I used TCP/TLS to connect to the Docker engine. The problem started when I switched to using named pipes.
Any ideas how to fix?
If anyone comes across this post: I had the same problem. I'm using docker-toolbox and noticed an error message in the terminal:
Error getting IP address: Something went wrong running an SSH command!
command : ip addr show dev eth1
err : exit status 255
output :
docker is configured to use the default machine with IP For help getting started, check out the docs at https://docs.docker.com
The solution was to reconfigure the default virtual machine. Run these commands in a terminal:
$ docker-machine rm default
$ docker-machine create --driver virtualbox default
Then run Docker Quickstart Terminal.
BTW, if you then come across an issue that the docker start is stuck at "Waiting for ip..." please follow this post for the solution.

Resources