简体   繁体   中英

How to run docker exec from php?

Trying to run docker exec from php under Nginx I get the following error:

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/konfetki_db_1/json: dial unix /var/run/docker.sock: connect: permission denied

This works from command line but it says permission denied while I'm trying to run from php under nginx with www-data instead of root.

Is there any way to run this?

I solved problem by this:

Add docker group
$ sudo groupadd docker
Add your current user to docker group
$ sudo usermod -aG docker www-data
Switch session to docker group
$ newgrp - docker
Run an example to test
$ docker run hello-world

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM