Closed matteo-bombelli closed 7 years ago
Do you have db services config like this?
- ./db/data:/var/lib/mysql
When i input docker-compose build
with db server ,I got this error.
So, I input sudo chown -R $USER:$USER /db/data
in order to got data permission.And I tried "docker-compose build" without the error.
docker-compose.yml
version: '3'
services:
db:
build:
./db
command: mysqld --default-authentication-plugin=mysql_native_password
ports:
- "3306:3306"
volumes:
- ./db/data:/var/lib/mysql
env_file:
- mysql.env
privileged: true
Restarting docker worked for me as well.
I solved it by changing the owner from root to me to the /var/run/docker.sock
. I don't know why the apt package installs as root.
$ sudo show derp:derp /var/run/docker.sock
Ran into a similar issue just now, took me a few hours to figure out the cause.
Story goes like this: we use Jenkins for CI and it runs tests for our main service with docker-compose as it relies on few other services. A coworker pushed a brach and Jenkins just failed to build it no matter what though the code and tests were perfectly fine. The problem appeared to be the following:
"$GIT_BRANCH-$RANDOMISH_HASH"
and curious part is that it truncates string from the beginning.-
), and the resulting directory name generated by Jenkins ended up starting with -
.docker-compose
in that folder, and by default docker-compose uses directory name as a prefix to name containers.-
) and that appears to be an illegal character for a docker container's name to start with.docker-compose
fails with a generic error with a misleading "Couldn't connect to Docker daemon - is it running?" message.Solution in my case was specifying custom project name (-p
) that would be used instead of default directory name:
docker-compose -f docker-compose.ci.yml -p "$SANITIZED_GIT_BRANCH" build
@alberto56 Fixed work:
chown -R user:user .
Also, update your .dockerignore if there's anything that's not supposed to be shipped to docker to build.
try this add sudo thats it
sudo docker-compose up
the solution for me is add my user to docker group, thanks that you do not must use sudo when using docker https://techoverflow.net/2017/03/01/solving-docker-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/
In my case if user not have permisions to /var/run/docker.sock
docker-compose tryed connect to http+docker://localhost
.
sudo usermod -a -G docker $USER
may fix that.
at this point https://github.com/docker/compose/issues/4181#issuecomment-317120015 restart PC will fix this problem
CentOS
I have to say, I solved by disconnect and reconnect to the server...
tl;dr stop unnecessary comments Guys. I think that restarting should not be part of ANY issue in GitHub. Please. It distracts us from what we are doing by non useful notifications. Keep in mind that commenting here is intended to add value to the issue itself. Restarting is not solving it because is happening again. In some point in particular the socket is stuck and so once if someone finds anything else that was not commented earlier in this thread adds value, then please do comment, then if not, please avoid creating notifications :) - sorry for the long thing.
sudo chown $USER:docker /var/run/docker.sock
works for me.
sudo which docker-compose
up works fine for me on Ubuntu 16.
It looks like several different access problems. I've got this problem on new Fedora 28 and resolved it by disabling selinux.
mine solved by typing sudo dockerd //then sudo docker-compose up -d
SET a volume with "/var/run/docker.sock:/var/run/docker.sock"
and will work
It worked after I restarted the server :)
Mine was just because of docker-compose
not being on PATH
. @pelican's answer resolved it
simply follow up the instruction mentioned in this issue and restart your machine.
Just doing this worked for me:
sudo apt-get purge golang-docker-credential-helpers
Just faced case where it worked and few rows of shell later (without any package install/upgrade), it is throwing this error. Just tried other projects and it builds so I feel something broken with docker cache or related internals to this image.. Docker image prune, restarting docker service or OS does not work. Docker is installed correctly (without need of sudoing)..
Edit: system prune and removing this particular container solved the issue
For me it was my user not being a member of the docker group. To solve...
sudo usermod -aG docker ${USER}
Then either logout & back in again, orsudo su - ${USER}
to receive the updated config in your terminal
that's the correct solution
sudo docker-compose run .......
worked for me :)
I had the same problems, and fixed restarting my docker, thank you a lot
The answer is on Docker documentation on postinstall steps section: https://docs.docker.com/install/linux/linux-postinstall/
As reported on doc:
The Docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo
This is why it works executing the command with sudo.
If you instead want your custom user to connect to docker ( as in my case ) you should add it on docker group with:
sudo usermod -aG docker $USER
In fact the ownership for the docker socket are:
srw-rw---- 1 root docker 0 Oct 3 11:31 /var/run/docker.sock
After this, as reported on doc, you should log out and log back in or restart if you're testing on a virtual machine.
I've tested into an Ubuntu 14.04 virtual machine running on Parallel and I didn't need to restart it. I just needed to login again to solve the issue.
NOTE Take a look on warning indicated on documentation, cause "docker" group grants privileges equivalent to the root user. So adding an user to that group can be a security issue according to your scenario.
run the command as root
export DOCKER_HOST = 127.0.0.1
and then locate yourself in the folder of your docker-compose.yml and execute the command:
su docker-compose up
As written in previous comments, trying to build each service individually gives more usefull error messages. I had this error because my image name was in uppercase inside the docker-compose.yml. Changing both service name and service image properties resolved the problem.
Just restart docker and it will work perfectly.
Run: service docker restart
and then run any docker command that you want.
u need to add your user to docker group to avoid "sudo docker ..." sudo usermod -aG docker username
Is your user in docker user group ?
sudo usermod -aG docker ${USER}
Check this article: https://medium.com/@ibrahimgunduz34/if-you-faced-an-issue-like-couldnt-connect-to-docker-daemon-at-http-docker-localunixsocket-is-27b35f17d09d
it was not working for me also . I have just added sudo before command and it istarted working..
sudo dockerd
gives me
Segmentation fault
so my problem is that the docker daemon isn't running, but I don't know what I should do
I found this useful
I upgraded my docker-compose
from 1.16.1
to 1.23.1
, solved it!
I am not sure what happened, I restarted my PC and it started working!!
i had the same problem and for me the reason why a restart fixed it was, that after the installation my user was added to the docker group, but this group change had only become effective through a relogin.
I encountered this today due to a mistake I made in my docker-compose.yml file.
I accidentally included the volumes:
key declaration twice, and this resulted in a failure to map docker.sock into an inner container. The mistake looked like this:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
volumes:
- datafiles:/datafiles
Which should just have said:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- datafiles:/datafiles
I discovered that when you declare two volumes sections like this, the first one is ignored. The container was, of course, not able to perform docker commands because of that.
I had the same problem, however I was able to solve it either running the docker as a root or applying execution permissions.
I used this link https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04 on Executing the Docker Command Without Sudo section.
A slightly offtopic question, for quite some time I’m looking for documentation or references regarding the http+docker://
schema definition. Does anybody here have a URL or reference to this schema? Thanks!
I had this problem, but realized the docker-compose error message was tremendously unhelpful and misleading. To find the actual cause I just docker build <service>
manually for each service in my docker-compose.yml until I found one that refused to build. In my case, it was a permissions issue with __pycache__
in the service directory.
I had the same issue and none of the solutions were helping. I tried Rosso84 idea. sudo service docker stop sudo dockerd Now I can run docker-compose up successfully. A little strangeness continues - sudo docker-compose up says command not found.
it worked for me: sudo groupadd docker sudo gpasswd -a $USER docker
Either do a newgrp docker or log out/in to activate the changes to groups. newgrp docker
I had this issue when using an unset build arg, that was then used in the tag of my FROM
image. Fix: Set the build arg to something other than a blank string.
restarting the server solved it for me
If you are non-root user, then try to add the user to docker permission
sudo usermod -a -G docker theUser
I got it fixed by rebooting my Ubuntu as well....
Hi ,
problem solved with sudo before the command ;) ,
Thanks, Moatez
It's a permission Issue.
- sudo chown $USER:docker /var/run/docker.sock
This worked for me in a ubuntu 18 setup.
I am not sure what happened, I restarted my PC and it started working!!
Take your like, sir
just type sudo
before your docker-compose
command!
I know that there is another issue of the same type but the other issue is closed and I tried all the solutions proposed but with no effect.
still not working:
I'm part of the docker group
I'm using also sudo
The process is up
The DOCKER_HOST variable is unset or 127.0.0.1
Reconnected the user
Restarted the server
I think that I've tried all the possible configurations am I right?
Specs:
OS: Ubuntu 14.04.04 on Virtualbox on Windows 10 Home.
Docker version 1.12.3, build 6b644ec
Thank You!