hieuhtr / Blog

Don’t be lazy. Don’t make excuses. No one cares. Work fucking harder.
Other
6 stars 2 forks source link

Run docker-compose in user jenkins #63

Open hieuhtr opened 7 years ago

hieuhtr commented 7 years ago

Problem:

Root cause & Solution:

User jenkins doesn't have permission to read/write docker unix socket

$ ls -l /var/run/docker.sock
srw-rw---- 1 root docker 0 Aug 14 09:21 /var/run/docker.sock

Switch to user ubuntu/root to add user jenkins to docker group Try to run the following command to add to the group

$ sudo usermod -a -G docker jenkins

Run the following command to find out what groups you belong to

# groups $USER
$ groups ubuntu
ubuntu : ubuntu adm dialout cdrom floppy sudo audio dip video plugdev netdev lxd docker

Restart jenkins service, and logout-login jenkins to apply

Export environment:

$ export DOCKER_HOST=127.0.0.1