简体   繁体   English

安装 Composer 依赖项期间 Docker composer 命令失败

[英]Docker composer command failed during install composer dependencies

I am setting up a deployment server.我正在设置部署服务器。 I installed docker and running docker container with a docker-composer.yaml generated by phpdocker.io.我安装了 docker 并使用由 phpdocker.io 生成的 docker docker-composer.yaml运行 docker 容器。 And I also installed jenkins.而且我还安装了詹金斯。 All setup is on EC2 instance.所有设置都在 EC2 实例上。 Everything works perfectly.一切正常。

During a push to master in github, jenkins need to make a pull and run some commands in EC2 instance.在 github 中推送到 master 期间,jenkins 需要在 EC2 实例中拉取并运行一些命令。 When I try to install composer dependencies I am getting below errors:当我尝试安装 Composer 依赖项时,出现以下错误:

docker-compose exec php-fpm composer install
Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
Build step 'Execute shell' marked build as failure
Finished: FAILURE

I try to look for many solutions but it seems somehow jenkins is not able to find docker, or not able to communicate with docker.我尝试寻找许多解决方案,但似乎 jenkins 无法找到 docker,或者无法与 docker 通信。

One of the solution which mention is docker is not running.提到的解决方案之一是 docker 未运行。 I am logged into EC2 instance and I am sure it's running.我已登录 EC2 实例,并且确定它正在运行。 Also I added docker to sudo.我还向 sudo 添加了 docker。 Just to confirm here is output of $ id -nG只是为了确认这里是$ id -nG输出

$ id -nG
ubuntu adm dialout cdrom floppy sudo audio dip video plugdev lxd netdev docker

As mentioned in comments, I tried to add sudo正如评论中提到的,我试图添加 sudo

$ sudo docker-compose exec php-fpm composer install
sudo: no tty present and no askpass program specified
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Any ideas how to solve this error?任何想法如何解决这个错误? If you need more information please feel free to ask.如果您需要更多信息,请随时询问。

Thanks谢谢

Running shell scripts that have contain sudo commands in them from jenkins might not run as expected.从 jenkins 运行其中包含 sudo 命令的 shell 脚本可能无法按预期运行。 To fix this, follow along Simple steps: 1. On ubuntu based systems, run " $ sudo visudo " 2. this will open /etc/sudoers file.要解决此问题,请按照以下简单步骤操作: 1. 在基于 ubuntu 的系统上,运行“ $ sudo visudo ” 2. 这将打开 /etc/sudoers 文件。 3. If your jenkins user is already in that file, then modify to look like this: 3. 如果您的 jenkins 用户已经在该文件中,则修改为如下所示:

jenkins ALL=(ALL) NOPASSWD: ALL 4. save the file by doing Ctrl+O (dont save in tmp file. save in /etc/sudoers, confirm overwrite) 5. Exit by doing Ctrl+X 6. Relaunch your jenkins job 7. you shouldnt see that error message again :) jenkins ALL=(ALL) NOPASSWD: ALL 4. 通过执行 Ctrl+O 保存文件(不要保存在 tmp 文件中。保存在 /etc/sudoers 中,确认覆盖) 5. 通过执行 Ctrl+X 退出 6. 重新启动您的 jenkins 工作7. 你不应该再看到那个错误信息 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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