How can I log into a running docker instance?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












poking docker to see how it works:



ubuntu@ip-172-31-14-19:~$ 
ubuntu@ip-172-31-14-19:~$ sudo docker run --net=host -d -t jmar71n/freepbx
2792243260a8de33d1a775d115188e601fc556e500b5ad085e09b4133d0f3d06
ubuntu@ip-172-31-14-19:~$
ubuntu@ip-172-31-14-19:~$ sudo docker run -it jmar71n/freepbx bash
root@46f45b8973c3:/#
root@46f45b8973c3:/# exit
exit
ubuntu@ip-172-31-14-19:~$
ubuntu@ip-172-31-14-19:~$ sudo docker run -it jmar71n/freepbx bash
root@813557bf8922:/#
root@813557bf8922:/# echo $PS1
[e]0;u@h: wa]$debian_chroot:+($debian_chroot)u@h:w$
root@813557bf8922:/#


Now, is each run a new instance? Is that why the prompt changes? The hostname is a unique ID for each run?



How would I login to the first instance, with --net=host?



When I try the exec flag, it fails:



ubuntu@ip-172-31-14-19:~$ 
ubuntu@ip-172-31-14-19:~$ sudo docker exec -it jmar71n/freepbx bash
Error: No such container: jmar71n/freepbx
ubuntu@ip-172-31-14-19:~$


Why? What's the correct way to login to that instance?



ubuntu@ip-172-31-14-19:~$ 
ubuntu@ip-172-31-14-19:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 20c44cd7596f 2 days ago 123MB
hello-world latest 725dcfab7d63 2 weeks ago 1.84kB
jmar71n/freepbx latest 8dda2a58fde1 19 months ago 1.54GB
ubuntu@ip-172-31-14-19:~$






share|improve this question


























    up vote
    1
    down vote

    favorite












    poking docker to see how it works:



    ubuntu@ip-172-31-14-19:~$ 
    ubuntu@ip-172-31-14-19:~$ sudo docker run --net=host -d -t jmar71n/freepbx
    2792243260a8de33d1a775d115188e601fc556e500b5ad085e09b4133d0f3d06
    ubuntu@ip-172-31-14-19:~$
    ubuntu@ip-172-31-14-19:~$ sudo docker run -it jmar71n/freepbx bash
    root@46f45b8973c3:/#
    root@46f45b8973c3:/# exit
    exit
    ubuntu@ip-172-31-14-19:~$
    ubuntu@ip-172-31-14-19:~$ sudo docker run -it jmar71n/freepbx bash
    root@813557bf8922:/#
    root@813557bf8922:/# echo $PS1
    [e]0;u@h: wa]$debian_chroot:+($debian_chroot)u@h:w$
    root@813557bf8922:/#


    Now, is each run a new instance? Is that why the prompt changes? The hostname is a unique ID for each run?



    How would I login to the first instance, with --net=host?



    When I try the exec flag, it fails:



    ubuntu@ip-172-31-14-19:~$ 
    ubuntu@ip-172-31-14-19:~$ sudo docker exec -it jmar71n/freepbx bash
    Error: No such container: jmar71n/freepbx
    ubuntu@ip-172-31-14-19:~$


    Why? What's the correct way to login to that instance?



    ubuntu@ip-172-31-14-19:~$ 
    ubuntu@ip-172-31-14-19:~$ sudo docker images
    REPOSITORY TAG IMAGE ID CREATED SIZE
    ubuntu latest 20c44cd7596f 2 days ago 123MB
    hello-world latest 725dcfab7d63 2 weeks ago 1.84kB
    jmar71n/freepbx latest 8dda2a58fde1 19 months ago 1.54GB
    ubuntu@ip-172-31-14-19:~$






    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      poking docker to see how it works:



      ubuntu@ip-172-31-14-19:~$ 
      ubuntu@ip-172-31-14-19:~$ sudo docker run --net=host -d -t jmar71n/freepbx
      2792243260a8de33d1a775d115188e601fc556e500b5ad085e09b4133d0f3d06
      ubuntu@ip-172-31-14-19:~$
      ubuntu@ip-172-31-14-19:~$ sudo docker run -it jmar71n/freepbx bash
      root@46f45b8973c3:/#
      root@46f45b8973c3:/# exit
      exit
      ubuntu@ip-172-31-14-19:~$
      ubuntu@ip-172-31-14-19:~$ sudo docker run -it jmar71n/freepbx bash
      root@813557bf8922:/#
      root@813557bf8922:/# echo $PS1
      [e]0;u@h: wa]$debian_chroot:+($debian_chroot)u@h:w$
      root@813557bf8922:/#


      Now, is each run a new instance? Is that why the prompt changes? The hostname is a unique ID for each run?



      How would I login to the first instance, with --net=host?



      When I try the exec flag, it fails:



      ubuntu@ip-172-31-14-19:~$ 
      ubuntu@ip-172-31-14-19:~$ sudo docker exec -it jmar71n/freepbx bash
      Error: No such container: jmar71n/freepbx
      ubuntu@ip-172-31-14-19:~$


      Why? What's the correct way to login to that instance?



      ubuntu@ip-172-31-14-19:~$ 
      ubuntu@ip-172-31-14-19:~$ sudo docker images
      REPOSITORY TAG IMAGE ID CREATED SIZE
      ubuntu latest 20c44cd7596f 2 days ago 123MB
      hello-world latest 725dcfab7d63 2 weeks ago 1.84kB
      jmar71n/freepbx latest 8dda2a58fde1 19 months ago 1.54GB
      ubuntu@ip-172-31-14-19:~$






      share|improve this question














      poking docker to see how it works:



      ubuntu@ip-172-31-14-19:~$ 
      ubuntu@ip-172-31-14-19:~$ sudo docker run --net=host -d -t jmar71n/freepbx
      2792243260a8de33d1a775d115188e601fc556e500b5ad085e09b4133d0f3d06
      ubuntu@ip-172-31-14-19:~$
      ubuntu@ip-172-31-14-19:~$ sudo docker run -it jmar71n/freepbx bash
      root@46f45b8973c3:/#
      root@46f45b8973c3:/# exit
      exit
      ubuntu@ip-172-31-14-19:~$
      ubuntu@ip-172-31-14-19:~$ sudo docker run -it jmar71n/freepbx bash
      root@813557bf8922:/#
      root@813557bf8922:/# echo $PS1
      [e]0;u@h: wa]$debian_chroot:+($debian_chroot)u@h:w$
      root@813557bf8922:/#


      Now, is each run a new instance? Is that why the prompt changes? The hostname is a unique ID for each run?



      How would I login to the first instance, with --net=host?



      When I try the exec flag, it fails:



      ubuntu@ip-172-31-14-19:~$ 
      ubuntu@ip-172-31-14-19:~$ sudo docker exec -it jmar71n/freepbx bash
      Error: No such container: jmar71n/freepbx
      ubuntu@ip-172-31-14-19:~$


      Why? What's the correct way to login to that instance?



      ubuntu@ip-172-31-14-19:~$ 
      ubuntu@ip-172-31-14-19:~$ sudo docker images
      REPOSITORY TAG IMAGE ID CREATED SIZE
      ubuntu latest 20c44cd7596f 2 days ago 123MB
      hello-world latest 725dcfab7d63 2 weeks ago 1.84kB
      jmar71n/freepbx latest 8dda2a58fde1 19 months ago 1.54GB
      ubuntu@ip-172-31-14-19:~$








      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '17 at 12:21

























      asked Nov 20 '17 at 12:14









      Thufir

      634733




      634733




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          Docker run, creates a new instance (para virtualised) environment from a given image.



          To log in to a given instance, you need to run docker exec but you need to execute docker exec with the id of the container you are looking to log into. This can be attained from the command:



          docker ps -a


          Then with the id attained, log into the container with:



          docker exec -it <containerid> bash





          share|improve this answer






















          • the <containerid> is not running...tried a bunch. ?
            – Thufir
            Nov 20 '17 at 12:40










          • That then suggests an issue with the way the image has been built. There is probably an issue with the entry point.
            – Raman Sailopal
            Nov 20 '17 at 13:05






          • 1




            While both can be used for isolating processes, paravirtualization and containers are two very different technologies.
            – Anthony Geoghegan
            Nov 20 '17 at 14:13











          • ok, works fine. not sure what the prob was last time. thx.
            – Thufir
            Nov 22 '17 at 9:05

















          up vote
          2
          down vote













          When you execute run command, you create new container each time.



          You execute run with options -it so you are being connected inside docker container, that's why your prompt is changing. So, all commands you execute with a new prompt will be executed inside the container.



          When you say exit you terminate your active process (bash since you pass it as a parameter during creation) and your container stops since it lives only as long as the main process with PID 1 lives.



          In order to connect to the instance, first, run it with -d in detached mode and then you can run docker attach. docs You can get an ID of your container by docker ps -a. Same with docker exec -it <containerID> bash.






          share|improve this answer






















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f405757%2fhow-can-i-log-into-a-running-docker-instance%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            Docker run, creates a new instance (para virtualised) environment from a given image.



            To log in to a given instance, you need to run docker exec but you need to execute docker exec with the id of the container you are looking to log into. This can be attained from the command:



            docker ps -a


            Then with the id attained, log into the container with:



            docker exec -it <containerid> bash





            share|improve this answer






















            • the <containerid> is not running...tried a bunch. ?
              – Thufir
              Nov 20 '17 at 12:40










            • That then suggests an issue with the way the image has been built. There is probably an issue with the entry point.
              – Raman Sailopal
              Nov 20 '17 at 13:05






            • 1




              While both can be used for isolating processes, paravirtualization and containers are two very different technologies.
              – Anthony Geoghegan
              Nov 20 '17 at 14:13











            • ok, works fine. not sure what the prob was last time. thx.
              – Thufir
              Nov 22 '17 at 9:05














            up vote
            0
            down vote



            accepted










            Docker run, creates a new instance (para virtualised) environment from a given image.



            To log in to a given instance, you need to run docker exec but you need to execute docker exec with the id of the container you are looking to log into. This can be attained from the command:



            docker ps -a


            Then with the id attained, log into the container with:



            docker exec -it <containerid> bash





            share|improve this answer






















            • the <containerid> is not running...tried a bunch. ?
              – Thufir
              Nov 20 '17 at 12:40










            • That then suggests an issue with the way the image has been built. There is probably an issue with the entry point.
              – Raman Sailopal
              Nov 20 '17 at 13:05






            • 1




              While both can be used for isolating processes, paravirtualization and containers are two very different technologies.
              – Anthony Geoghegan
              Nov 20 '17 at 14:13











            • ok, works fine. not sure what the prob was last time. thx.
              – Thufir
              Nov 22 '17 at 9:05












            up vote
            0
            down vote



            accepted







            up vote
            0
            down vote



            accepted






            Docker run, creates a new instance (para virtualised) environment from a given image.



            To log in to a given instance, you need to run docker exec but you need to execute docker exec with the id of the container you are looking to log into. This can be attained from the command:



            docker ps -a


            Then with the id attained, log into the container with:



            docker exec -it <containerid> bash





            share|improve this answer














            Docker run, creates a new instance (para virtualised) environment from a given image.



            To log in to a given instance, you need to run docker exec but you need to execute docker exec with the id of the container you are looking to log into. This can be attained from the command:



            docker ps -a


            Then with the id attained, log into the container with:



            docker exec -it <containerid> bash






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 20 '17 at 14:11









            Thufir

            634733




            634733










            answered Nov 20 '17 at 12:27









            Raman Sailopal

            1,18117




            1,18117











            • the <containerid> is not running...tried a bunch. ?
              – Thufir
              Nov 20 '17 at 12:40










            • That then suggests an issue with the way the image has been built. There is probably an issue with the entry point.
              – Raman Sailopal
              Nov 20 '17 at 13:05






            • 1




              While both can be used for isolating processes, paravirtualization and containers are two very different technologies.
              – Anthony Geoghegan
              Nov 20 '17 at 14:13











            • ok, works fine. not sure what the prob was last time. thx.
              – Thufir
              Nov 22 '17 at 9:05
















            • the <containerid> is not running...tried a bunch. ?
              – Thufir
              Nov 20 '17 at 12:40










            • That then suggests an issue with the way the image has been built. There is probably an issue with the entry point.
              – Raman Sailopal
              Nov 20 '17 at 13:05






            • 1




              While both can be used for isolating processes, paravirtualization and containers are two very different technologies.
              – Anthony Geoghegan
              Nov 20 '17 at 14:13











            • ok, works fine. not sure what the prob was last time. thx.
              – Thufir
              Nov 22 '17 at 9:05















            the <containerid> is not running...tried a bunch. ?
            – Thufir
            Nov 20 '17 at 12:40




            the <containerid> is not running...tried a bunch. ?
            – Thufir
            Nov 20 '17 at 12:40












            That then suggests an issue with the way the image has been built. There is probably an issue with the entry point.
            – Raman Sailopal
            Nov 20 '17 at 13:05




            That then suggests an issue with the way the image has been built. There is probably an issue with the entry point.
            – Raman Sailopal
            Nov 20 '17 at 13:05




            1




            1




            While both can be used for isolating processes, paravirtualization and containers are two very different technologies.
            – Anthony Geoghegan
            Nov 20 '17 at 14:13





            While both can be used for isolating processes, paravirtualization and containers are two very different technologies.
            – Anthony Geoghegan
            Nov 20 '17 at 14:13













            ok, works fine. not sure what the prob was last time. thx.
            – Thufir
            Nov 22 '17 at 9:05




            ok, works fine. not sure what the prob was last time. thx.
            – Thufir
            Nov 22 '17 at 9:05












            up vote
            2
            down vote













            When you execute run command, you create new container each time.



            You execute run with options -it so you are being connected inside docker container, that's why your prompt is changing. So, all commands you execute with a new prompt will be executed inside the container.



            When you say exit you terminate your active process (bash since you pass it as a parameter during creation) and your container stops since it lives only as long as the main process with PID 1 lives.



            In order to connect to the instance, first, run it with -d in detached mode and then you can run docker attach. docs You can get an ID of your container by docker ps -a. Same with docker exec -it <containerID> bash.






            share|improve this answer


























              up vote
              2
              down vote













              When you execute run command, you create new container each time.



              You execute run with options -it so you are being connected inside docker container, that's why your prompt is changing. So, all commands you execute with a new prompt will be executed inside the container.



              When you say exit you terminate your active process (bash since you pass it as a parameter during creation) and your container stops since it lives only as long as the main process with PID 1 lives.



              In order to connect to the instance, first, run it with -d in detached mode and then you can run docker attach. docs You can get an ID of your container by docker ps -a. Same with docker exec -it <containerID> bash.






              share|improve this answer
























                up vote
                2
                down vote










                up vote
                2
                down vote









                When you execute run command, you create new container each time.



                You execute run with options -it so you are being connected inside docker container, that's why your prompt is changing. So, all commands you execute with a new prompt will be executed inside the container.



                When you say exit you terminate your active process (bash since you pass it as a parameter during creation) and your container stops since it lives only as long as the main process with PID 1 lives.



                In order to connect to the instance, first, run it with -d in detached mode and then you can run docker attach. docs You can get an ID of your container by docker ps -a. Same with docker exec -it <containerID> bash.






                share|improve this answer














                When you execute run command, you create new container each time.



                You execute run with options -it so you are being connected inside docker container, that's why your prompt is changing. So, all commands you execute with a new prompt will be executed inside the container.



                When you say exit you terminate your active process (bash since you pass it as a parameter during creation) and your container stops since it lives only as long as the main process with PID 1 lives.



                In order to connect to the instance, first, run it with -d in detached mode and then you can run docker attach. docs You can get an ID of your container by docker ps -a. Same with docker exec -it <containerID> bash.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 1 '17 at 9:01

























                answered Nov 20 '17 at 14:19









                kirill-a

                2,0351820




                2,0351820



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f405757%2fhow-can-i-log-into-a-running-docker-instance%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?