Reputation: 450
I am setting up a deployment server. I installed docker and running docker container with a docker-composer.yaml
generated by phpdocker.io. And I also installed jenkins. All setup is on EC2 instance. Everything works perfectly.
During a push to master in github, jenkins need to make a pull and run some commands in EC2 instance. When I try to install composer dependencies I am getting below errors:
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.
One of the solution which mention is docker is not running. I am logged into EC2 instance and I am sure it's running. Also I added docker to sudo.
Just to confirm here is output of $ 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 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
Upvotes: 2
Views: 1461
Reputation: 58
Running shell scripts that have contain sudo commands in them from jenkins might not run as expected. To fix this, follow along Simple steps: 1. On ubuntu based systems, run " $ sudo visudo " 2. this will open /etc/sudoers file. 3. If your jenkins user is already in that file, then modify to look like this:
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 :)
Upvotes: 2