turnbullpress / dockerbook-code

The code and configuration examples from The Docker Book (http://www.dockerbook.com)
930 stars 581 forks source link

Listing 5.70 - Running Docker-Jenkins image #47

Closed stevepop closed 6 years ago

stevepop commented 7 years ago

Hi,

I am a Mac user and currently following the code on Chapter 5. I have built the Jenkins image, however when I run the container with the following, it returns the container ID and exits. According to the instruction, I created jenkins_home in /private/var/jenkins_home. I also granted permission to the folder as follows; sudo chown -R 1000 /private/var/jenkins_home Then I ran the image as follows;

docker run -d -p 8080:8080 -p 50000:50000 -v /private/var/jenkins_home:/var/jenkins_home -v /private/var/run/docker.sock:/var/run/docker.sock --name jenkins stevepop/jenkins

It returns the container ID but when I run docker ps, nothing displays. When I ran docker ps -a, I see the following;

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS               NAMES
decb7004b6fb        stevepop/jenkins    "/bin/tini -- /usr..."   4 seconds ago       Exited (1) 3 seconds ago                       jenkins

I suspect strongly that the problem is the volume mapping. When I remove the volumes, the container runs fine.

What could be the problem here please?

jamtur01 commented 7 years ago

Any log output with an error?

stevepop commented 7 years ago

Hi @jamtur01,

Yes I got the following errors;

docker logs 9ef85f0fc8dc
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?
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?
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
jamtur01 commented 7 years ago

Is the UID of the jenkins user 1000?

stevepop commented 7 years ago

The container does not run so not sure how I can check the UID of jenkins user? The image below is the permisisons on the host

permissions_osx
jamtur01 commented 7 years ago

You can run the container without the volume and check.

stevepop commented 7 years ago

Yes the UID of jenkins user is 1000

jenkins_uid
stevepop commented 7 years ago

HI @jamtur01, were you able to reproduce this issue? Is there an alternative way of getting past this point?

jamtur01 commented 7 years ago

Sorry I haven't had a chance to replicate it. I won't have until the weekend. Do you have a Linux box you could use in the meantime?

stevepop commented 7 years ago

Okay, I will try on a Linux box in the meantime, thanks.