How can I debug a docker container initialization?Cannot connect to MongoDB in dockerModify hosts file in...

Is exact Kanji stroke length important?

How does the UK government determine the size of a mandate?

How to be diplomatic in refusing to write code that breaches the privacy of our users

Are student evaluations of teaching assistants read by others in the faculty?

Why not increase contact surface when reentering the atmosphere?

Class Action - which options I have?

How do we know the LHC results are robust?

What is the difference between "behavior" and "behaviour"?

How to draw lines on a tikz-cd diagram

when is out of tune ok?

System.debug(JSON.Serialize(o)) Not longer shows full string

For a non-Jew, is there a punishment for not observing the 7 Noahide Laws?

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

A particular customize with green line and letters for subfloat

Applicability of Single Responsibility Principle

How do I go from 300 unfinished/half written blog posts, to published posts?

Did Dumbledore lie to Harry about how long he had James Potter's invisibility cloak when he was examining it? If so, why?

Why, precisely, is argon used in neutrino experiments?

Lay out the Carpet

Sequence of Tenses: Translating the subjunctive

How can I kill an app using Terminal?

Unreliable Magic - Is it worth it?

What does "I’d sit this one out, Cap," imply or mean in the context?

Was Spock the First Vulcan in Starfleet?



How can I debug a docker container initialization?


Cannot connect to MongoDB in dockerModify hosts file in dockerfileDoes using Docker mean I can run ASP.NET MVC in a container residing on Linux?Nginx proxy_pass to wordpress docker containerConfusion with Jenkins Docker Plugin and Jenkins Docker SlavesJenkins Docker build slave - npm cache not workingBest strategy for deploying Docker to Elastic BeanstalkK8s & Docker - ideal image design for sensitive params on GCPIssue with 64-bit (host) inodes vs. 32-bit inodes in osxfs in Ubuntu 16.04 containerHAProxy as Docker container not routing as a reverse proxy













76















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?



EDIT: Thanks to Andrew D. I now know what's wrong with the code above (I left it so his answer can be understood). Now the issue is still how might I debug something like this or get some insides at why ls -l failed why ls did not.



EDIT: The -D=true might give more output, though not in my case...










share|improve this question

























  • Please make the effort to mark one of the answers as "accepted", thanks!

    – Brian Topping
    Dec 23 '17 at 3:04
















76















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?



EDIT: Thanks to Andrew D. I now know what's wrong with the code above (I left it so his answer can be understood). Now the issue is still how might I debug something like this or get some insides at why ls -l failed why ls did not.



EDIT: The -D=true might give more output, though not in my case...










share|improve this question

























  • Please make the effort to mark one of the answers as "accepted", thanks!

    – Brian Topping
    Dec 23 '17 at 3:04














76












76








76


16






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?



EDIT: Thanks to Andrew D. I now know what's wrong with the code above (I left it so his answer can be understood). Now the issue is still how might I debug something like this or get some insides at why ls -l failed why ls did not.



EDIT: The -D=true might give more output, though not in my case...










share|improve this question
















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?



EDIT: Thanks to Andrew D. I now know what's wrong with the code above (I left it so his answer can be understood). Now the issue is still how might I debug something like this or get some insides at why ls -l failed why ls did not.



EDIT: The -D=true might give more output, though not in my case...







docker debug






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 20 '14 at 8:56







estani

















asked May 19 '14 at 15:28









estaniestani

7411611




7411611













  • Please make the effort to mark one of the answers as "accepted", thanks!

    – Brian Topping
    Dec 23 '17 at 3:04



















  • Please make the effort to mark one of the answers as "accepted", thanks!

    – Brian Topping
    Dec 23 '17 at 3:04

















Please make the effort to mark one of the answers as "accepted", thanks!

– Brian Topping
Dec 23 '17 at 3:04





Please make the effort to mark one of the answers as "accepted", thanks!

– Brian Topping
Dec 23 '17 at 3:04










5 Answers
5






active

oldest

votes


















75














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>


You should now see some output from the failed image startup.



As @alexkb suggested in a comment: docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. In this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id>.






share|improve this answer


























  • Very helpful! New to docker and was trying to get portainer running. Solved it with these debugging steps. Found someone on Medium.com with the same problem: medium.com/@jameson_37151/…

    – Jameson
    Mar 12 '17 at 3:41













  • I get "container not found"!?

    – demented hedgehog
    Feb 4 '18 at 23:17











  • Strange. Just to make sure, @dementedhedgehog did you try copy the hex-id from the log message ending in "(from xxx/xxx:latest) die"?

    – Peter Lamberg
    Feb 5 '18 at 10:26






  • 1





    Thank you so much this answer, it is a life saver. Only thing to add is that docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. So in this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id> as suggested by this answer to see why things aren't booting.

    – alexkb
    Jul 13 '18 at 2:43








  • 1





    @alexkb Thanks! I added your suggestion to the end of the answer so others may find it more easily.

    – Peter Lamberg
    Jul 14 '18 at 11:16



















17














Well the best I have found out so far is:



#stop the current demon and start it in debug modus
sudo service docker stop
dockerd -D # --debug


The just start the client from a new shell. The misconception was to think the client actually does anything at all... well it's just communicating with the daemon, so you don't want to debug the client but the daemon itself (normally).






share|improve this answer

































    11














    In my case, the -a (attach to STDOUT/STDERR) flag was enough:



    user@machine:~$ docker start -a server_name
    Error: The directory named as part of the path /log/log_path/app.log does not exist.
    For help, use /usr/bin/supervisord -h


    It showed the startup error (in our case, a missing log path used by supervisord). I assume most container startup errors would show up here as well.






    share|improve this answer































      3














      I can't answer your question on how to make docker output more complete but I can tell you that in-place regex replacing a string in a .so file is a bit insane: the string only has so much space allocated to it, and if you change the file offsets of other entries, the elf file becomes corrupted. Try running objdump or readelf on your .so file after running the perl command (before LD_LIBRARY_PATH change) outside of a container -- dollars to donuts it is now corrupt.



      The reason it works in this sadly necessary hack is because "tmp" and "etc" are the same string length so no offsets change. Consider the directory /dkr or similar if you prefer not to use /tmp.



      If you MUST take this approach and your desired paths are unchangeable, rebuild the library and change the default path for /etc/hosts in the source. Or better, when building your modified libnss_files.so rename it to something like libnss_altfiles.so and change nsswitch.conf to use hosts: altfiles when starting your docker container (unless docker has bind mounted nsswitch.conf as well, then you can't change it). This will let you have the libnss_altfiles.so in parallel with your normal libraries in the base system. If docker does bind-mount nsswitch.conf, leave a copy of your rebuilt libnss_files.so in your /lib-override directory ready to be loaded by LD_LIBRARY_PATH.



      As a heads up, suid/sgid binaries ignore LD_LIBRARY_PATH and LD_PRELOAD, so some stuff is going to break (read: go back to using the default /etc/hosts) if you use those variables.






      share|improve this answer


























      • Thanks a lot for the great insight... I was too fast and see now what's happening. I still don't know why getting the stat needs to resolve a host (ls -l) while the simple file listing (ls), does not...

        – estani
        May 20 '14 at 8:39



















      0














      Sometimes, you can find useful error messages by sshing into the node running the docker daemon and then doing:



      $ tail -f /var/log/containers/* /var/log/docker.log 2>&1


      On 'Docker Community edition' on Mac OS, you can connect into the docker vm by doing:



      $  screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty





      share|improve this answer























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "2"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f596994%2fhow-can-i-debug-a-docker-container-initialization%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        75














        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>


        You should now see some output from the failed image startup.



        As @alexkb suggested in a comment: docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. In this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id>.






        share|improve this answer


























        • Very helpful! New to docker and was trying to get portainer running. Solved it with these debugging steps. Found someone on Medium.com with the same problem: medium.com/@jameson_37151/…

          – Jameson
          Mar 12 '17 at 3:41













        • I get "container not found"!?

          – demented hedgehog
          Feb 4 '18 at 23:17











        • Strange. Just to make sure, @dementedhedgehog did you try copy the hex-id from the log message ending in "(from xxx/xxx:latest) die"?

          – Peter Lamberg
          Feb 5 '18 at 10:26






        • 1





          Thank you so much this answer, it is a life saver. Only thing to add is that docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. So in this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id> as suggested by this answer to see why things aren't booting.

          – alexkb
          Jul 13 '18 at 2:43








        • 1





          @alexkb Thanks! I added your suggestion to the end of the answer so others may find it more easily.

          – Peter Lamberg
          Jul 14 '18 at 11:16
















        75














        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>


        You should now see some output from the failed image startup.



        As @alexkb suggested in a comment: docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. In this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id>.






        share|improve this answer


























        • Very helpful! New to docker and was trying to get portainer running. Solved it with these debugging steps. Found someone on Medium.com with the same problem: medium.com/@jameson_37151/…

          – Jameson
          Mar 12 '17 at 3:41













        • I get "container not found"!?

          – demented hedgehog
          Feb 4 '18 at 23:17











        • Strange. Just to make sure, @dementedhedgehog did you try copy the hex-id from the log message ending in "(from xxx/xxx:latest) die"?

          – Peter Lamberg
          Feb 5 '18 at 10:26






        • 1





          Thank you so much this answer, it is a life saver. Only thing to add is that docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. So in this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id> as suggested by this answer to see why things aren't booting.

          – alexkb
          Jul 13 '18 at 2:43








        • 1





          @alexkb Thanks! I added your suggestion to the end of the answer so others may find it more easily.

          – Peter Lamberg
          Jul 14 '18 at 11:16














        75












        75








        75







        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>


        You should now see some output from the failed image startup.



        As @alexkb suggested in a comment: docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. In this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id>.






        share|improve this answer















        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>


        You should now see some output from the failed image startup.



        As @alexkb suggested in a comment: docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. In this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id>.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jul 14 '18 at 11:15

























        answered Dec 22 '15 at 13:24









        Peter LambergPeter Lamberg

        86676




        86676













        • Very helpful! New to docker and was trying to get portainer running. Solved it with these debugging steps. Found someone on Medium.com with the same problem: medium.com/@jameson_37151/…

          – Jameson
          Mar 12 '17 at 3:41













        • I get "container not found"!?

          – demented hedgehog
          Feb 4 '18 at 23:17











        • Strange. Just to make sure, @dementedhedgehog did you try copy the hex-id from the log message ending in "(from xxx/xxx:latest) die"?

          – Peter Lamberg
          Feb 5 '18 at 10:26






        • 1





          Thank you so much this answer, it is a life saver. Only thing to add is that docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. So in this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id> as suggested by this answer to see why things aren't booting.

          – alexkb
          Jul 13 '18 at 2:43








        • 1





          @alexkb Thanks! I added your suggestion to the end of the answer so others may find it more easily.

          – Peter Lamberg
          Jul 14 '18 at 11:16



















        • Very helpful! New to docker and was trying to get portainer running. Solved it with these debugging steps. Found someone on Medium.com with the same problem: medium.com/@jameson_37151/…

          – Jameson
          Mar 12 '17 at 3:41













        • I get "container not found"!?

          – demented hedgehog
          Feb 4 '18 at 23:17











        • Strange. Just to make sure, @dementedhedgehog did you try copy the hex-id from the log message ending in "(from xxx/xxx:latest) die"?

          – Peter Lamberg
          Feb 5 '18 at 10:26






        • 1





          Thank you so much this answer, it is a life saver. Only thing to add is that docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. So in this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id> as suggested by this answer to see why things aren't booting.

          – alexkb
          Jul 13 '18 at 2:43








        • 1





          @alexkb Thanks! I added your suggestion to the end of the answer so others may find it more easily.

          – Peter Lamberg
          Jul 14 '18 at 11:16

















        Very helpful! New to docker and was trying to get portainer running. Solved it with these debugging steps. Found someone on Medium.com with the same problem: medium.com/@jameson_37151/…

        – Jameson
        Mar 12 '17 at 3:41







        Very helpful! New to docker and was trying to get portainer running. Solved it with these debugging steps. Found someone on Medium.com with the same problem: medium.com/@jameson_37151/…

        – Jameson
        Mar 12 '17 at 3:41















        I get "container not found"!?

        – demented hedgehog
        Feb 4 '18 at 23:17





        I get "container not found"!?

        – demented hedgehog
        Feb 4 '18 at 23:17













        Strange. Just to make sure, @dementedhedgehog did you try copy the hex-id from the log message ending in "(from xxx/xxx:latest) die"?

        – Peter Lamberg
        Feb 5 '18 at 10:26





        Strange. Just to make sure, @dementedhedgehog did you try copy the hex-id from the log message ending in "(from xxx/xxx:latest) die"?

        – Peter Lamberg
        Feb 5 '18 at 10:26




        1




        1





        Thank you so much this answer, it is a life saver. Only thing to add is that docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. So in this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id> as suggested by this answer to see why things aren't booting.

        – alexkb
        Jul 13 '18 at 2:43







        Thank you so much this answer, it is a life saver. Only thing to add is that docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. So in this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id> as suggested by this answer to see why things aren't booting.

        – alexkb
        Jul 13 '18 at 2:43






        1




        1





        @alexkb Thanks! I added your suggestion to the end of the answer so others may find it more easily.

        – Peter Lamberg
        Jul 14 '18 at 11:16





        @alexkb Thanks! I added your suggestion to the end of the answer so others may find it more easily.

        – Peter Lamberg
        Jul 14 '18 at 11:16













        17














        Well the best I have found out so far is:



        #stop the current demon and start it in debug modus
        sudo service docker stop
        dockerd -D # --debug


        The just start the client from a new shell. The misconception was to think the client actually does anything at all... well it's just communicating with the daemon, so you don't want to debug the client but the daemon itself (normally).






        share|improve this answer






























          17














          Well the best I have found out so far is:



          #stop the current demon and start it in debug modus
          sudo service docker stop
          dockerd -D # --debug


          The just start the client from a new shell. The misconception was to think the client actually does anything at all... well it's just communicating with the daemon, so you don't want to debug the client but the daemon itself (normally).






          share|improve this answer




























            17












            17








            17







            Well the best I have found out so far is:



            #stop the current demon and start it in debug modus
            sudo service docker stop
            dockerd -D # --debug


            The just start the client from a new shell. The misconception was to think the client actually does anything at all... well it's just communicating with the daemon, so you don't want to debug the client but the daemon itself (normally).






            share|improve this answer















            Well the best I have found out so far is:



            #stop the current demon and start it in debug modus
            sudo service docker stop
            dockerd -D # --debug


            The just start the client from a new shell. The misconception was to think the client actually does anything at all... well it's just communicating with the daemon, so you don't want to debug the client but the daemon itself (normally).







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 20 '18 at 7:59









            Community

            1




            1










            answered May 26 '14 at 9:07









            estaniestani

            7411611




            7411611























                11














                In my case, the -a (attach to STDOUT/STDERR) flag was enough:



                user@machine:~$ docker start -a server_name
                Error: The directory named as part of the path /log/log_path/app.log does not exist.
                For help, use /usr/bin/supervisord -h


                It showed the startup error (in our case, a missing log path used by supervisord). I assume most container startup errors would show up here as well.






                share|improve this answer




























                  11














                  In my case, the -a (attach to STDOUT/STDERR) flag was enough:



                  user@machine:~$ docker start -a server_name
                  Error: The directory named as part of the path /log/log_path/app.log does not exist.
                  For help, use /usr/bin/supervisord -h


                  It showed the startup error (in our case, a missing log path used by supervisord). I assume most container startup errors would show up here as well.






                  share|improve this answer


























                    11












                    11








                    11







                    In my case, the -a (attach to STDOUT/STDERR) flag was enough:



                    user@machine:~$ docker start -a server_name
                    Error: The directory named as part of the path /log/log_path/app.log does not exist.
                    For help, use /usr/bin/supervisord -h


                    It showed the startup error (in our case, a missing log path used by supervisord). I assume most container startup errors would show up here as well.






                    share|improve this answer













                    In my case, the -a (attach to STDOUT/STDERR) flag was enough:



                    user@machine:~$ docker start -a server_name
                    Error: The directory named as part of the path /log/log_path/app.log does not exist.
                    For help, use /usr/bin/supervisord -h


                    It showed the startup error (in our case, a missing log path used by supervisord). I assume most container startup errors would show up here as well.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 29 '16 at 13:27









                    claytondclaytond

                    22636




                    22636























                        3














                        I can't answer your question on how to make docker output more complete but I can tell you that in-place regex replacing a string in a .so file is a bit insane: the string only has so much space allocated to it, and if you change the file offsets of other entries, the elf file becomes corrupted. Try running objdump or readelf on your .so file after running the perl command (before LD_LIBRARY_PATH change) outside of a container -- dollars to donuts it is now corrupt.



                        The reason it works in this sadly necessary hack is because "tmp" and "etc" are the same string length so no offsets change. Consider the directory /dkr or similar if you prefer not to use /tmp.



                        If you MUST take this approach and your desired paths are unchangeable, rebuild the library and change the default path for /etc/hosts in the source. Or better, when building your modified libnss_files.so rename it to something like libnss_altfiles.so and change nsswitch.conf to use hosts: altfiles when starting your docker container (unless docker has bind mounted nsswitch.conf as well, then you can't change it). This will let you have the libnss_altfiles.so in parallel with your normal libraries in the base system. If docker does bind-mount nsswitch.conf, leave a copy of your rebuilt libnss_files.so in your /lib-override directory ready to be loaded by LD_LIBRARY_PATH.



                        As a heads up, suid/sgid binaries ignore LD_LIBRARY_PATH and LD_PRELOAD, so some stuff is going to break (read: go back to using the default /etc/hosts) if you use those variables.






                        share|improve this answer


























                        • Thanks a lot for the great insight... I was too fast and see now what's happening. I still don't know why getting the stat needs to resolve a host (ls -l) while the simple file listing (ls), does not...

                          – estani
                          May 20 '14 at 8:39
















                        3














                        I can't answer your question on how to make docker output more complete but I can tell you that in-place regex replacing a string in a .so file is a bit insane: the string only has so much space allocated to it, and if you change the file offsets of other entries, the elf file becomes corrupted. Try running objdump or readelf on your .so file after running the perl command (before LD_LIBRARY_PATH change) outside of a container -- dollars to donuts it is now corrupt.



                        The reason it works in this sadly necessary hack is because "tmp" and "etc" are the same string length so no offsets change. Consider the directory /dkr or similar if you prefer not to use /tmp.



                        If you MUST take this approach and your desired paths are unchangeable, rebuild the library and change the default path for /etc/hosts in the source. Or better, when building your modified libnss_files.so rename it to something like libnss_altfiles.so and change nsswitch.conf to use hosts: altfiles when starting your docker container (unless docker has bind mounted nsswitch.conf as well, then you can't change it). This will let you have the libnss_altfiles.so in parallel with your normal libraries in the base system. If docker does bind-mount nsswitch.conf, leave a copy of your rebuilt libnss_files.so in your /lib-override directory ready to be loaded by LD_LIBRARY_PATH.



                        As a heads up, suid/sgid binaries ignore LD_LIBRARY_PATH and LD_PRELOAD, so some stuff is going to break (read: go back to using the default /etc/hosts) if you use those variables.






                        share|improve this answer


























                        • Thanks a lot for the great insight... I was too fast and see now what's happening. I still don't know why getting the stat needs to resolve a host (ls -l) while the simple file listing (ls), does not...

                          – estani
                          May 20 '14 at 8:39














                        3












                        3








                        3







                        I can't answer your question on how to make docker output more complete but I can tell you that in-place regex replacing a string in a .so file is a bit insane: the string only has so much space allocated to it, and if you change the file offsets of other entries, the elf file becomes corrupted. Try running objdump or readelf on your .so file after running the perl command (before LD_LIBRARY_PATH change) outside of a container -- dollars to donuts it is now corrupt.



                        The reason it works in this sadly necessary hack is because "tmp" and "etc" are the same string length so no offsets change. Consider the directory /dkr or similar if you prefer not to use /tmp.



                        If you MUST take this approach and your desired paths are unchangeable, rebuild the library and change the default path for /etc/hosts in the source. Or better, when building your modified libnss_files.so rename it to something like libnss_altfiles.so and change nsswitch.conf to use hosts: altfiles when starting your docker container (unless docker has bind mounted nsswitch.conf as well, then you can't change it). This will let you have the libnss_altfiles.so in parallel with your normal libraries in the base system. If docker does bind-mount nsswitch.conf, leave a copy of your rebuilt libnss_files.so in your /lib-override directory ready to be loaded by LD_LIBRARY_PATH.



                        As a heads up, suid/sgid binaries ignore LD_LIBRARY_PATH and LD_PRELOAD, so some stuff is going to break (read: go back to using the default /etc/hosts) if you use those variables.






                        share|improve this answer















                        I can't answer your question on how to make docker output more complete but I can tell you that in-place regex replacing a string in a .so file is a bit insane: the string only has so much space allocated to it, and if you change the file offsets of other entries, the elf file becomes corrupted. Try running objdump or readelf on your .so file after running the perl command (before LD_LIBRARY_PATH change) outside of a container -- dollars to donuts it is now corrupt.



                        The reason it works in this sadly necessary hack is because "tmp" and "etc" are the same string length so no offsets change. Consider the directory /dkr or similar if you prefer not to use /tmp.



                        If you MUST take this approach and your desired paths are unchangeable, rebuild the library and change the default path for /etc/hosts in the source. Or better, when building your modified libnss_files.so rename it to something like libnss_altfiles.so and change nsswitch.conf to use hosts: altfiles when starting your docker container (unless docker has bind mounted nsswitch.conf as well, then you can't change it). This will let you have the libnss_altfiles.so in parallel with your normal libraries in the base system. If docker does bind-mount nsswitch.conf, leave a copy of your rebuilt libnss_files.so in your /lib-override directory ready to be loaded by LD_LIBRARY_PATH.



                        As a heads up, suid/sgid binaries ignore LD_LIBRARY_PATH and LD_PRELOAD, so some stuff is going to break (read: go back to using the default /etc/hosts) if you use those variables.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited May 23 '17 at 12:41









                        Community

                        1




                        1










                        answered May 19 '14 at 21:01









                        Andrew DomaszekAndrew Domaszek

                        4,75011025




                        4,75011025













                        • Thanks a lot for the great insight... I was too fast and see now what's happening. I still don't know why getting the stat needs to resolve a host (ls -l) while the simple file listing (ls), does not...

                          – estani
                          May 20 '14 at 8:39



















                        • Thanks a lot for the great insight... I was too fast and see now what's happening. I still don't know why getting the stat needs to resolve a host (ls -l) while the simple file listing (ls), does not...

                          – estani
                          May 20 '14 at 8:39

















                        Thanks a lot for the great insight... I was too fast and see now what's happening. I still don't know why getting the stat needs to resolve a host (ls -l) while the simple file listing (ls), does not...

                        – estani
                        May 20 '14 at 8:39





                        Thanks a lot for the great insight... I was too fast and see now what's happening. I still don't know why getting the stat needs to resolve a host (ls -l) while the simple file listing (ls), does not...

                        – estani
                        May 20 '14 at 8:39











                        0














                        Sometimes, you can find useful error messages by sshing into the node running the docker daemon and then doing:



                        $ tail -f /var/log/containers/* /var/log/docker.log 2>&1


                        On 'Docker Community edition' on Mac OS, you can connect into the docker vm by doing:



                        $  screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty





                        share|improve this answer




























                          0














                          Sometimes, you can find useful error messages by sshing into the node running the docker daemon and then doing:



                          $ tail -f /var/log/containers/* /var/log/docker.log 2>&1


                          On 'Docker Community edition' on Mac OS, you can connect into the docker vm by doing:



                          $  screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty





                          share|improve this answer


























                            0












                            0








                            0







                            Sometimes, you can find useful error messages by sshing into the node running the docker daemon and then doing:



                            $ tail -f /var/log/containers/* /var/log/docker.log 2>&1


                            On 'Docker Community edition' on Mac OS, you can connect into the docker vm by doing:



                            $  screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty





                            share|improve this answer













                            Sometimes, you can find useful error messages by sshing into the node running the docker daemon and then doing:



                            $ tail -f /var/log/containers/* /var/log/docker.log 2>&1


                            On 'Docker Community edition' on Mac OS, you can connect into the docker vm by doing:



                            $  screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 13 mins ago









                            user674669user674669

                            1043




                            1043






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Server Fault!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f596994%2fhow-can-i-debug-a-docker-container-initialization%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

                                Список ссавців Італії Природоохоронні статуси | Список |...

                                Українські прізвища Зміст Історичні відомості |...