jenkins slave on docker does not have permissions to /var/run/docker.sock

145 views
Skip to first unread message

Piotr Bracha

unread,
Apr 17, 2019, 9:23:06 AM4/17/19
to jenkins...@googlegroups.com
Hello
I need to resolve last problem related with building on dockerized jenkins slave. Slave didn't see "docker" command but I googled that I should run image with below:

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

Of course it did not resolve problem with seeing of "docker" command. I should run image with:

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

After this slave on docker container started seeing "docker" command. Now in Jenkinsfile I build an image and I have an error:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:
dial unix /var/run/docker.sock: connect: permission denied

Of course I have checked I should add user to group docker but it didn't help, because two parameters mentioned above maps /var/run/docker.sock and /usr/bin/docker to proper inside docker container which has own users etc. Fortunately on host machine I have "jenkins" user and also on dockerized jenkins slave. I have created docker group with specific GID (this same which is on host machine)
Group on host machine:
root@jenkins:/var/run# cat /etc/group | grep docker
docker:x:999:jenkins

Group on docker slave:
root@b06e55959ae9:/var/run# cat /etc/group | grep docker
docker:x:999:jenkins

Still nothing. Can anybody help me with this?

--
Pozdrawiam / Kind regards, 
Piotr Bracha
Administrator Systemów
Vasco Electronics sp. z o.o. S.K.A.
al. Pokoju 1, CTA/350 
31-548 Kraków
NIP 677 236 91 51
 
Vasco Electronics Spółka z ograniczoną odpowiedzialnością Spółka Komandytowo-Akcyjna, Al. Pokoju 1, CTA/350, 31-548 Kraków, Polska, NIP: 6772369151, REGON: 122581850, zarejestrowana w Sądzie Rejonowym dla Krakowa Śródmieścia XI Wydział KRS pod nr KRS: 0000421705, Kapitał zakładowy 50 000 zł (słownie: pięćdziesiąt tysięcy złotych) w całości wpłacony. Klauzula Bezpieczeństwa: treść tej wiadomości wraz z załącznikami stanowią informacje chronione przed ujawnieniem. Jeśli wiadomość ta nie jest przeznaczona dla Ciebie uprzedzamy, że ujawnianie, kopiowanie, rozpowszechnianie lub korzystanie z niej lub z załączników jest zabronione. Jeśli otrzymałeś tę wiadomość przez pomyłkę, uprzejmie prosimy o niezwłoczne zawiadomienie nadawcy i odesłanie jej z powrotem wraz z załącznikami a także usunięcie ze swoich systemów.

Dirk Heinrichs

unread,
Apr 17, 2019, 11:07:59 AM4/17/19
to jenkins...@googlegroups.com
Am Mittwoch, den 17.04.2019, 11:22 +0200 schrieb Piotr Bracha:

Slave didn't see "docker" command

Wonder why it would be needed. We run builds on Docker agents, too, but never needed the docker command itself inside the container.

Bye...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

Piotr Bracha

unread,
Apr 17, 2019, 11:11:42 AM4/17/19
to jenkins...@googlegroups.com
I need, because I build an application image on this docker jenkins slave and then I need push it to repo. I use "docker build" and "docker push" commands. They are visible from slave but unable to execute due to permission error.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6dbfdf6a4adca0e05e187e45d5c8ec065ea6610c.camel%40opentext.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages