0

I run my Jenkins as a Docker container with the command below

docker run \  
  -u root \  
  --rm \  
  -d \  
  -p 8081:8080 \  
  -p 50000:50000 \  
  -v /data/jenkins-data:/var/jenkins_home \  
  -v /var/run/docker.sock:/var/run/docker.sock \  
  jenkinsci/blueocean

From time to time, the jenkins container will exit. I even can't find it with "docker ps -a" command, so that I can't get any logs for troubleshooting.

Is there any way I can check the reason why a docker container exits like this?

1
  • 1
    remove --rm flag to let the container not be removed post termination. Then you can use docker ps -a followed by docker logs <container id> to see why
    – Sathyajith Bhat
    Commented Jun 13, 2019 at 7:13

1 Answer 1

0

I think the best way to check where it exits from is first creating a yaml file out of that docker run command and then doing a docker-compose up without the -d. this will continue logging all the messages from the container until it exits and maybe will stop there(sometimes it continues to log for those containers that have a restarting problem). Read more about the yaml files here

4
  • 1
    I think you mean yaml
    – xenoid
    Commented Jun 13, 2019 at 8:15
  • Yes I have changed it now .. thank you Commented Jun 13, 2019 at 8:24
  • Thanks for you information, I will study about it.
    – Adan
    Commented Jun 14, 2019 at 2:12
  • @Adan please do, its must nicer and easier to handle than running these commands .. the intro link is docs.docker.com/compose/overview Commented Jun 14, 2019 at 8:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .