Tagged: ,

  • How can I debug a docker container initialization?

     Joseph updated 10 months, 3 weeks ago 2 Members · 2 Posts
  • Tom

    August 21, 2020 at 3:28 pm

    I had an issue with a container, even though it builds perfectly it does not properly start. The cause is a workaround I’ve added to the Dockerfile (for having a self-configured /etc/hosts routing)

    RUN mkdir -p -- /lib-override /etc-override && cp /lib/libnss_files.so.2 /lib-override
    ADD hosts.template /etc-override/hosts
    RUN perl -pi -e 's:/etc/hosts:/etc-override/hosts:g' /lib-override/libnss_files.so.2
    ENV LD_LIBRARY_PATH /lib-override

    Obviously there’s some error in there, but I wonder how can I get more info on what docker is doing while running. for example, this works:

    $ docker run image ls
    usr bin ...

    But this doesn’t:

    $ docker run image ls -l

    There is nothing in the logs and I can’t call an interactive shell either. I can use strace to see what’s happening but I was hoping theres a better way.

    Is there any way I can set docker to be more verbose?

  • Joseph

    August 21, 2020 at 4:01 pm

    Docker events command may help and Docker logs command can fetch logs even after the image failed to start.

    First start docker events in the background to see whats going on.

    docker events&

    Then run your failing docker run ... command. Then you should see something like the following on screen:

    2015-12-22T15:13:05.503402713+02:00 xxxxxxxacd8ca86df9eac5fd5466884c0b42a06293ccff0b5101b5987f5da07d: (from xxx/xxx:latest) die

    Then you can get the startup hex id from previous message or the output of the run command. Then you can use it with the logs command:

    docker logs <copy the instance id from docker events messages on screen>

Viewing 1 - 2 of 2 replies

Log in to reply.

Original Post
0 of 0 posts June 2018