Akhil Dev – Super Charged Digital Marketing Strategy for Your Business › Ask Questions › General Questions › How can I debug a docker container initialization?
- MemberAugust 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?
- MemberAugust 21, 2020 at 4:01 pm
eventscommand may help and Docker logs command can fetch logs even after the image failed to start.
docker eventsin the background to see whats going on.
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>
Log in to reply.