Skip to content
This repository has been archived by the owner on Oct 26, 2019. It is now read-only.

Permission denied #239

Closed
yoieh opened this issue Mar 9, 2017 · 8 comments
Closed

Permission denied #239

yoieh opened this issue Mar 9, 2017 · 8 comments

Comments

@yoieh
Copy link

yoieh commented Mar 9, 2017

Cant get this to work at all:

Im trying to return running containers inside of a container ruing php, apache and this library.

<?
use Docker\Docker;
$docker = new Docker();
$containers = $docker->getContainerManager()->findAll();
?>
[error] [client 10.0.0.15] PHP Fatal error:  Uncaught exception 'Http\\Client\\Exception\\NetworkException' with message 'Permission denied' in /var/www/vendor/php-http/socket-client/src/Client.php:112\nStack trace:\n#0 /var/www/vendor/php-http/socket-client/src/Client.php(80): Http\\Client\\Socket\\Client->createSocket(Object(GuzzleHttp\\Psr7\\Request), 'unix:///var/run...', false)\n#1 /var/www/vendor/php-http/client-common/src/HttpClientDecorator.php(27): Http\\Client\\Socket\\Client->sendRequest(Object(GuzzleHttp\\Psr7\\Request))\n#2 /var/www/vendor/php-http/client-common/src/PluginClient.php(81): Http\\Client\\Common\\EmulatedHttpAsyncClient->sendRequest(Object(GuzzleHttp\\Psr7\\Request))\n#3 /var/www/vendor/php-http/plugins/src/DecoderPlugin.php(67): Http\\Client\\Common\\PluginClient->Http\\Client\\Common\\{closure}(Object(GuzzleHttp\\Psr7\\Request))\n#4 /var/www/vendor/php-http/client-common/src/PluginClient.php(156): Http\\Client\\Plugin\\DecoderPlugin->handleRequest(Object(GuzzleHttp\\Psr7\\Request), Object(Closure), Object(Closure))\n#5 /var/www/vendor/php-http/plugins/src/Content in /var/www/vendor/php-http/socket-client/src/Client.php on line 112

This tells me that is some thing to do with uids or gids.
I have added docker group to the container gid 2000 and www-data has a gid of 33.
On my linux vm the docker groups guid is 2000 and www-data has an gid of 33.

Running ubuntu 16 tls as vm with docker installed and container created with:

sudo docker run -d --restart=always -p 8040:80 --name site -v /var/www/site/:/var/www/ -v /root/_dockerlogs/site/:/var/log/apache2 -v /var/run.docker.sock:/var/run/docker.sock cfd44bc6f9fb

I have now tied to add my user to docker group in VM. I thought docker group should have access to the docker socket but has not and probably my problem.

How do I then solve this problem and use this library?

@CliffLin
Copy link

CliffLin commented Mar 9, 2017

-v /var/run.docker.sock:/var/run/docker.so"c"k ?

@yoieh
Copy link
Author

yoieh commented Mar 10, 2017

This was just a typo in the issue

-v /var/run.docker.sock:/var/run/docker.so"c"k ?

@joelwurtz
Copy link
Member

joelwurtz commented Mar 10, 2017

Your user inside the container (then the www-data) should be attached to the docker group gid of the host (which is 2000), so you should normally execute this command inside your container :

usermod -aG docker www-data

@yoieh
Copy link
Author

yoieh commented Mar 13, 2017

This i have already done from inside and outside the docker container.

usermod -aG docker www-data

cat /etc/group
...
docker:x:2000:www-data
...

@CliffLin
Copy link

Can you show the info about cat /etc/group | grep docker inside and outside of container

@yoieh
Copy link
Author

yoieh commented Mar 13, 2017

Its the same sorry i think i found and fixed the issue:

-v /var/run.docker.sock:/var/run/docker.sock

/var/run.docker.sock should be /var/run/docker/sock a mistake from my side.

Thanks for the response!

@joelwurtz
Copy link
Member

Glad you find a solution

@joblesspoet
Copy link

Hi everyone,
I'm facing the same issue in centos, Please help how to set the permission in centos, In ubuntu I had set the permission as per explained steps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants