最近在使用ddev进行drupal开发的是,出现Could not connect to a Docker provider的错误,,具体的错误内容如下:
zhangzhijun@debian:~/workspace/beginnerDrupal$ ddev config --project-type=drupal11 --docroot=web
Could not connect to a Docker provider. Please start or install a Docker provider.
For install help go to: https://ddev.readthedocs.io/en/stable/users/install/docker-installation/
zhangzhijun@debian:~/workspace/beginnerDrupal$
查了一些材料,大部分都可以通过重启docker解决了问题,但是我重启docker确并没有解决。仔细阅读了ddev的手册,其中docker引擎安装下面的有一段话:
Linux installation absolutely requires adding your Linux user to the docker group, and configuring the Docker daemon to start at boot. Don’t install rootless mode, it is not supported by DDEV. See Post-installation steps for Linux.
Don’t use sudo with the docker command. If you find yourself needing it, you haven’t finished the installation. You also shouldn’t use sudo with ddev unless it’s specifically for the ddev hostname command.
docker运行默认是需要root权限的,这些提示的是要求将当前用户加入docker group。参考文档中的描述,新建了docker group,且将当前用户加入到了docker group中,重新执行ddev config --project-type=drupal11 --docroot=web 的命令,确实可以执行了。
添加命令如下:
sudo groupadd docker
sudo usermod -aG docker $USER
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
执行情况如下:
zhangzhijun@debian:~/workspace/beginnerDrupal$ ddev config --project-type=drupal11 --docroot=web
Creating a new DDEV project config in the current directory (/home/zhangzhijun/workspace/beginnerDrupal)
Once completed, your configuration will be written to /home/zhangzhijun/workspace/beginnerDrupal/.ddev/config.yaml
Created docroot at /home/zhangzhijun/workspace/beginnerDrupal/web
Configuring a 'drupal11' project named 'beginnerDrupal' with docroot 'web' at '/home/zhangzhijun/workspace/beginnerDrupal/web'.
For full details use 'ddev describe'.
参考文档:
https://docs.docker.com/engine/install/linux-postinstall/
https://ddev.readthedocs.io/en/stable/users/install/docker-installation/#linux