-1

I am trying to run jenkins in a container. I am pulling and trying to run this container from docker hub official jenkins.

I am doing this as root user in an amazon aws ec2 machine in /root

Here is what I have:

root@ip-172-31-27-169:~# pwd
/root

root@ip-172-31-27-169:~# whoami

root

root@ip-172-31-27-169:~# ls -al 

total 32

drwx------  4 root root 4096 Jul 20 15:39 .

drwxr-xr-x 24 root root 4096 Jul 20 06:59 ..

-rw-------  1 root root 1934 Jul 20 09:00 .bash_history

-rw-r--r--  1 root root 3106 Oct 22  2015 .bashrc

drwxr-xr-x  2 root root 4096 Jul 20 15:25 jenkins_home

-rw-r--r--  1 root root  148 Aug 17  2015 .profile

drwx------  2 root root 4096 Jul 20 04:52 .ssh

-rw-------  1 root root 2994 Jul 20 15:36 .viminfo

root@ip-172-31-27-169:~# docker ps -a

CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                          PORTS               NAMES

cdde4f2e9d55        jenkins             "/bin/tini -- /usr..."   About a minute ago   Exited (1) About a minute ago                       gifted_swirles

64a6f038e1bc        jenkins             "/bin/tini -- /usr..."   2 minutes ago        Exited (1) About a minute ago                       compassionate_brown

55ae36a27756        jenkins             "/bin/tini -- /usr..."   6 minutes ago        Exited (1) 6 minutes ago                            xenodochial_fermat

c6c48ef6b917        jenkins             "/bin/tini -- /usr..."   6 minutes ago        Exited (1) 6 minutes ago                            kind_hoover


root@ip-172-31-27-169:~# docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

jenkins             latest              f426a52bafa9        12 days ago         810 MB

root@ip-172-31-27-169:~# docker run -p 8080:8080 -p 50000:50000 -v /root/jenkins_home:/var/jenkins_home jenkins

touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied

Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?

root@ip-172-31-27-169:~# 

I am trying to mount /var/jenkins_home volume of the container into /root/jenkins_home path. This is to save the jenkins data in case the container dies or stops for some reason.

How can I make this command succeed?

docker run -p 8080:8080 -p 50000:50000 -v /root/jenkins_home:/var/jenkins_home jenkins

Thank you

David
  • 1,469
  • 5
  • 33
  • 51

1 Answers1

1

If the ec2 virtual machine is a redhat linux, it may have the selinux enabled and you need to either disable it or provide for the right selinux properties for the /root/jenkins_home folder. If the ec2 vm is an ubuntu machine, it could have the apparmor enabled. The same things apply to this one too (disable or give proper permissions to folder).

The problems seems to be a permission problem as explained here. you can change the permissions of the folder to uid 1000 as explained here. with the following command :

chown -R 1000 /root/jenkins_home

and then rerun your docker image.

komarios
  • 147
  • 4