How to access root folder inside a Docker container












0















I am new to docker, and am attempting to build an image that involves performing an npm install. Some of our the dependencies are coming from private repos we have, and I am hitting an SSH related issue:



enter image description here



I realised I was not supplying any form of SSH details to my file, and came across various posts online about how to do this using args into the docker build command.



So taken from here, I have added the following to my dockerfile before the npm install command gets run:



ARG ssh_prv_key
ARG ssh_pub_key

RUN apt-get update &&
apt-get install -y
git
openssh-server
libmysqlclient-dev

# Authorize SSH Host
RUN mkdir -p /root/.ssh &&
chmod 0700 /root/.ssh &&
ssh-keyscan github.com > /root/.ssh/known_hosts

# Add the keys and set permissions
RUN echo "$ssh_prv_key" > /root/.ssh/id_rsa &&
echo "$ssh_pub_key" > /root/.ssh/id_rsa.pub &&
chmod 600 /root/.ssh/id_rsa &&
chmod 600 /root/.ssh/id_rsa.pub


So running the docker build command again with the correct args supplied, I do see further activity in the console that suggests my SSH key is being utilised:



enter image description here



But as you can see I am getting no hostkey alg messages and
I still getting the same 'Host key verification failed' error. I was wondering if I could view the log file it references in the error:



enter image description here



Do I need to get the image running in order to be able to connect to it and browse the 'root' folder?



I hope I have made sense, please be gentle I am a docker noob!



Thanks










share|improve this question



























    0















    I am new to docker, and am attempting to build an image that involves performing an npm install. Some of our the dependencies are coming from private repos we have, and I am hitting an SSH related issue:



    enter image description here



    I realised I was not supplying any form of SSH details to my file, and came across various posts online about how to do this using args into the docker build command.



    So taken from here, I have added the following to my dockerfile before the npm install command gets run:



    ARG ssh_prv_key
    ARG ssh_pub_key

    RUN apt-get update &&
    apt-get install -y
    git
    openssh-server
    libmysqlclient-dev

    # Authorize SSH Host
    RUN mkdir -p /root/.ssh &&
    chmod 0700 /root/.ssh &&
    ssh-keyscan github.com > /root/.ssh/known_hosts

    # Add the keys and set permissions
    RUN echo "$ssh_prv_key" > /root/.ssh/id_rsa &&
    echo "$ssh_pub_key" > /root/.ssh/id_rsa.pub &&
    chmod 600 /root/.ssh/id_rsa &&
    chmod 600 /root/.ssh/id_rsa.pub


    So running the docker build command again with the correct args supplied, I do see further activity in the console that suggests my SSH key is being utilised:



    enter image description here



    But as you can see I am getting no hostkey alg messages and
    I still getting the same 'Host key verification failed' error. I was wondering if I could view the log file it references in the error:



    enter image description here



    Do I need to get the image running in order to be able to connect to it and browse the 'root' folder?



    I hope I have made sense, please be gentle I am a docker noob!



    Thanks










    share|improve this question

























      0












      0








      0








      I am new to docker, and am attempting to build an image that involves performing an npm install. Some of our the dependencies are coming from private repos we have, and I am hitting an SSH related issue:



      enter image description here



      I realised I was not supplying any form of SSH details to my file, and came across various posts online about how to do this using args into the docker build command.



      So taken from here, I have added the following to my dockerfile before the npm install command gets run:



      ARG ssh_prv_key
      ARG ssh_pub_key

      RUN apt-get update &&
      apt-get install -y
      git
      openssh-server
      libmysqlclient-dev

      # Authorize SSH Host
      RUN mkdir -p /root/.ssh &&
      chmod 0700 /root/.ssh &&
      ssh-keyscan github.com > /root/.ssh/known_hosts

      # Add the keys and set permissions
      RUN echo "$ssh_prv_key" > /root/.ssh/id_rsa &&
      echo "$ssh_pub_key" > /root/.ssh/id_rsa.pub &&
      chmod 600 /root/.ssh/id_rsa &&
      chmod 600 /root/.ssh/id_rsa.pub


      So running the docker build command again with the correct args supplied, I do see further activity in the console that suggests my SSH key is being utilised:



      enter image description here



      But as you can see I am getting no hostkey alg messages and
      I still getting the same 'Host key verification failed' error. I was wondering if I could view the log file it references in the error:



      enter image description here



      Do I need to get the image running in order to be able to connect to it and browse the 'root' folder?



      I hope I have made sense, please be gentle I am a docker noob!



      Thanks










      share|improve this question














      I am new to docker, and am attempting to build an image that involves performing an npm install. Some of our the dependencies are coming from private repos we have, and I am hitting an SSH related issue:



      enter image description here



      I realised I was not supplying any form of SSH details to my file, and came across various posts online about how to do this using args into the docker build command.



      So taken from here, I have added the following to my dockerfile before the npm install command gets run:



      ARG ssh_prv_key
      ARG ssh_pub_key

      RUN apt-get update &&
      apt-get install -y
      git
      openssh-server
      libmysqlclient-dev

      # Authorize SSH Host
      RUN mkdir -p /root/.ssh &&
      chmod 0700 /root/.ssh &&
      ssh-keyscan github.com > /root/.ssh/known_hosts

      # Add the keys and set permissions
      RUN echo "$ssh_prv_key" > /root/.ssh/id_rsa &&
      echo "$ssh_pub_key" > /root/.ssh/id_rsa.pub &&
      chmod 600 /root/.ssh/id_rsa &&
      chmod 600 /root/.ssh/id_rsa.pub


      So running the docker build command again with the correct args supplied, I do see further activity in the console that suggests my SSH key is being utilised:



      enter image description here



      But as you can see I am getting no hostkey alg messages and
      I still getting the same 'Host key verification failed' error. I was wondering if I could view the log file it references in the error:



      enter image description here



      Do I need to get the image running in order to be able to connect to it and browse the 'root' folder?



      I hope I have made sense, please be gentle I am a docker noob!



      Thanks







      docker npm ssh dockerfile






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 13:42









      mindparsemindparse

      3,47293077




      3,47293077
























          1 Answer
          1






          active

          oldest

          votes


















          1














          The lines that start with —-> in the docker build output are valid Docker image IDs. You can pick any of these and docker run them:



          docker run --rm -it 59c45dac474a sh


          If a step is actually failing, one useful debugging trick is to launch the image built in the step before it and run the command by hand.



          Remember that anyone who has your image can do this; the way you’ve built it, if you ever push your image to any repository, your ssh private key is there for the taking, and you should probably consider it compromised. That’s doubly true since it will also be there in plain text in docker history output.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            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%2fstackoverflow.com%2fquestions%2f53301628%2fhow-to-access-root-folder-inside-a-docker-container%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            The lines that start with —-> in the docker build output are valid Docker image IDs. You can pick any of these and docker run them:



            docker run --rm -it 59c45dac474a sh


            If a step is actually failing, one useful debugging trick is to launch the image built in the step before it and run the command by hand.



            Remember that anyone who has your image can do this; the way you’ve built it, if you ever push your image to any repository, your ssh private key is there for the taking, and you should probably consider it compromised. That’s doubly true since it will also be there in plain text in docker history output.






            share|improve this answer




























              1














              The lines that start with —-> in the docker build output are valid Docker image IDs. You can pick any of these and docker run them:



              docker run --rm -it 59c45dac474a sh


              If a step is actually failing, one useful debugging trick is to launch the image built in the step before it and run the command by hand.



              Remember that anyone who has your image can do this; the way you’ve built it, if you ever push your image to any repository, your ssh private key is there for the taking, and you should probably consider it compromised. That’s doubly true since it will also be there in plain text in docker history output.






              share|improve this answer


























                1












                1








                1







                The lines that start with —-> in the docker build output are valid Docker image IDs. You can pick any of these and docker run them:



                docker run --rm -it 59c45dac474a sh


                If a step is actually failing, one useful debugging trick is to launch the image built in the step before it and run the command by hand.



                Remember that anyone who has your image can do this; the way you’ve built it, if you ever push your image to any repository, your ssh private key is there for the taking, and you should probably consider it compromised. That’s doubly true since it will also be there in plain text in docker history output.






                share|improve this answer













                The lines that start with —-> in the docker build output are valid Docker image IDs. You can pick any of these and docker run them:



                docker run --rm -it 59c45dac474a sh


                If a step is actually failing, one useful debugging trick is to launch the image built in the step before it and run the command by hand.



                Remember that anyone who has your image can do this; the way you’ve built it, if you ever push your image to any repository, your ssh private key is there for the taking, and you should probably consider it compromised. That’s doubly true since it will also be there in plain text in docker history output.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 14 '18 at 15:49









                David MazeDavid Maze

                13.5k31226




                13.5k31226
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • 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%2fstackoverflow.com%2fquestions%2f53301628%2fhow-to-access-root-folder-inside-a-docker-container%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

                    Bressuire

                    Vorschmack

                    Quarantine