Copying built OpenCV from one Docker image to another












0















Using this Dockerfile with just the important parts highlighted for simplicity:



RUN cd /opencv-$OPENCV_VERSION/cmake_binary 
&& cmake -DBUILD_TIFF=ON
&& make install

## Compress the openCV files so you can extract them from the docker easily
RUN tar cvzf opencv-$OPENCV_VERSION.tar.gz --directory=$OPENCV_INSTALL_PATH .


Now, I want to build my application in a new container, so as far as I understand the documentation I can go:



FROM docker-opencv-cuda:cv3.3.1_cuda8 AS opencv

COPY -from=opencv /opencv/ /opencv/


However, I get an error:




invalid from flag value opencv: pull access denied for opencv, repository does not exist or may require 'docker login'




Looking around, it seems that COPY -from is trying to reference either a private or public repository, but I'd like it to look for my local version as docker image ls reports:



REPOSITORY           TAG             IMAGE ID
docker-opencv-cuda cv3.3.1_cuda8 xxxx
docker-opencv-cuda cv3.3.1_cuda9 yyyy


How can I do what I want to do? Adding to a repository is not a valid option as later I will have proprietary code that I cannot share, etc.



UPDATE: I might have found a bug? I have Docker 18.09.0, and given the lines:



ARG CV_VERSION=cv3.3.1_cuda8
FROM docker-opencv-cuda:$CV_VERSION AS opencv

COPY -from=opencv /opencv/ /opencv/
COPY -from=docker-opencv-cuda:$CV_VERSION /opencv/ /opencv/
COPY -from=docker-opencv-cuda:cv3.3.1_cuda8 /opencv/ /opencv/


Only the third COPY with the full -from label works.



UPDATE 2: Docker newbie problem. My Dockerfile is incorrect as -from should not refer to the current FROM, so this is OK and does what I want:



ARG CV_VERSION=cv3.3.1_cuda8
FROM docker-opencv-cuda:$CV_VERSION AS opencv

# Switch context so the OpenCV files no longer exist in the current image
FROM another_package

COPY -from=opencv /opencv/ /opencv/
COPY -from=docker-opencv-cuda:$CV_VERSION /opencv/ /opencv/
COPY -from=docker-opencv-cuda:cv3.3.1_cuda8 /opencv/ /opencv/









share|improve this question





























    0















    Using this Dockerfile with just the important parts highlighted for simplicity:



    RUN cd /opencv-$OPENCV_VERSION/cmake_binary 
    && cmake -DBUILD_TIFF=ON
    && make install

    ## Compress the openCV files so you can extract them from the docker easily
    RUN tar cvzf opencv-$OPENCV_VERSION.tar.gz --directory=$OPENCV_INSTALL_PATH .


    Now, I want to build my application in a new container, so as far as I understand the documentation I can go:



    FROM docker-opencv-cuda:cv3.3.1_cuda8 AS opencv

    COPY -from=opencv /opencv/ /opencv/


    However, I get an error:




    invalid from flag value opencv: pull access denied for opencv, repository does not exist or may require 'docker login'




    Looking around, it seems that COPY -from is trying to reference either a private or public repository, but I'd like it to look for my local version as docker image ls reports:



    REPOSITORY           TAG             IMAGE ID
    docker-opencv-cuda cv3.3.1_cuda8 xxxx
    docker-opencv-cuda cv3.3.1_cuda9 yyyy


    How can I do what I want to do? Adding to a repository is not a valid option as later I will have proprietary code that I cannot share, etc.



    UPDATE: I might have found a bug? I have Docker 18.09.0, and given the lines:



    ARG CV_VERSION=cv3.3.1_cuda8
    FROM docker-opencv-cuda:$CV_VERSION AS opencv

    COPY -from=opencv /opencv/ /opencv/
    COPY -from=docker-opencv-cuda:$CV_VERSION /opencv/ /opencv/
    COPY -from=docker-opencv-cuda:cv3.3.1_cuda8 /opencv/ /opencv/


    Only the third COPY with the full -from label works.



    UPDATE 2: Docker newbie problem. My Dockerfile is incorrect as -from should not refer to the current FROM, so this is OK and does what I want:



    ARG CV_VERSION=cv3.3.1_cuda8
    FROM docker-opencv-cuda:$CV_VERSION AS opencv

    # Switch context so the OpenCV files no longer exist in the current image
    FROM another_package

    COPY -from=opencv /opencv/ /opencv/
    COPY -from=docker-opencv-cuda:$CV_VERSION /opencv/ /opencv/
    COPY -from=docker-opencv-cuda:cv3.3.1_cuda8 /opencv/ /opencv/









    share|improve this question



























      0












      0








      0








      Using this Dockerfile with just the important parts highlighted for simplicity:



      RUN cd /opencv-$OPENCV_VERSION/cmake_binary 
      && cmake -DBUILD_TIFF=ON
      && make install

      ## Compress the openCV files so you can extract them from the docker easily
      RUN tar cvzf opencv-$OPENCV_VERSION.tar.gz --directory=$OPENCV_INSTALL_PATH .


      Now, I want to build my application in a new container, so as far as I understand the documentation I can go:



      FROM docker-opencv-cuda:cv3.3.1_cuda8 AS opencv

      COPY -from=opencv /opencv/ /opencv/


      However, I get an error:




      invalid from flag value opencv: pull access denied for opencv, repository does not exist or may require 'docker login'




      Looking around, it seems that COPY -from is trying to reference either a private or public repository, but I'd like it to look for my local version as docker image ls reports:



      REPOSITORY           TAG             IMAGE ID
      docker-opencv-cuda cv3.3.1_cuda8 xxxx
      docker-opencv-cuda cv3.3.1_cuda9 yyyy


      How can I do what I want to do? Adding to a repository is not a valid option as later I will have proprietary code that I cannot share, etc.



      UPDATE: I might have found a bug? I have Docker 18.09.0, and given the lines:



      ARG CV_VERSION=cv3.3.1_cuda8
      FROM docker-opencv-cuda:$CV_VERSION AS opencv

      COPY -from=opencv /opencv/ /opencv/
      COPY -from=docker-opencv-cuda:$CV_VERSION /opencv/ /opencv/
      COPY -from=docker-opencv-cuda:cv3.3.1_cuda8 /opencv/ /opencv/


      Only the third COPY with the full -from label works.



      UPDATE 2: Docker newbie problem. My Dockerfile is incorrect as -from should not refer to the current FROM, so this is OK and does what I want:



      ARG CV_VERSION=cv3.3.1_cuda8
      FROM docker-opencv-cuda:$CV_VERSION AS opencv

      # Switch context so the OpenCV files no longer exist in the current image
      FROM another_package

      COPY -from=opencv /opencv/ /opencv/
      COPY -from=docker-opencv-cuda:$CV_VERSION /opencv/ /opencv/
      COPY -from=docker-opencv-cuda:cv3.3.1_cuda8 /opencv/ /opencv/









      share|improve this question
















      Using this Dockerfile with just the important parts highlighted for simplicity:



      RUN cd /opencv-$OPENCV_VERSION/cmake_binary 
      && cmake -DBUILD_TIFF=ON
      && make install

      ## Compress the openCV files so you can extract them from the docker easily
      RUN tar cvzf opencv-$OPENCV_VERSION.tar.gz --directory=$OPENCV_INSTALL_PATH .


      Now, I want to build my application in a new container, so as far as I understand the documentation I can go:



      FROM docker-opencv-cuda:cv3.3.1_cuda8 AS opencv

      COPY -from=opencv /opencv/ /opencv/


      However, I get an error:




      invalid from flag value opencv: pull access denied for opencv, repository does not exist or may require 'docker login'




      Looking around, it seems that COPY -from is trying to reference either a private or public repository, but I'd like it to look for my local version as docker image ls reports:



      REPOSITORY           TAG             IMAGE ID
      docker-opencv-cuda cv3.3.1_cuda8 xxxx
      docker-opencv-cuda cv3.3.1_cuda9 yyyy


      How can I do what I want to do? Adding to a repository is not a valid option as later I will have proprietary code that I cannot share, etc.



      UPDATE: I might have found a bug? I have Docker 18.09.0, and given the lines:



      ARG CV_VERSION=cv3.3.1_cuda8
      FROM docker-opencv-cuda:$CV_VERSION AS opencv

      COPY -from=opencv /opencv/ /opencv/
      COPY -from=docker-opencv-cuda:$CV_VERSION /opencv/ /opencv/
      COPY -from=docker-opencv-cuda:cv3.3.1_cuda8 /opencv/ /opencv/


      Only the third COPY with the full -from label works.



      UPDATE 2: Docker newbie problem. My Dockerfile is incorrect as -from should not refer to the current FROM, so this is OK and does what I want:



      ARG CV_VERSION=cv3.3.1_cuda8
      FROM docker-opencv-cuda:$CV_VERSION AS opencv

      # Switch context so the OpenCV files no longer exist in the current image
      FROM another_package

      COPY -from=opencv /opencv/ /opencv/
      COPY -from=docker-opencv-cuda:$CV_VERSION /opencv/ /opencv/
      COPY -from=docker-opencv-cuda:cv3.3.1_cuda8 /opencv/ /opencv/






      docker opencv dockerfile






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 2:57







      Ken Y-N

















      asked Nov 16 '18 at 2:03









      Ken Y-NKen Y-N

      7,838134773




      7,838134773
























          1 Answer
          1






          active

          oldest

          votes


















          1














          First map your local disk when start docker and copy data from docker into the local disk.



          such as:



          $ docker run --it -rm -v /your_path:/your_path  your_image
          # cp -rf /opencv /your_path
          # exit


          Then create your new docker, and copy the data from the local.






          share|improve this answer
























          • I was thinking about that as a workaround and I might just adopt that since as I note in my update COPY -from looks dodgy.

            – Ken Y-N
            Nov 16 '18 at 2:15











          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%2f53330437%2fcopying-built-opencv-from-one-docker-image-to-another%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














          First map your local disk when start docker and copy data from docker into the local disk.



          such as:



          $ docker run --it -rm -v /your_path:/your_path  your_image
          # cp -rf /opencv /your_path
          # exit


          Then create your new docker, and copy the data from the local.






          share|improve this answer
























          • I was thinking about that as a workaround and I might just adopt that since as I note in my update COPY -from looks dodgy.

            – Ken Y-N
            Nov 16 '18 at 2:15
















          1














          First map your local disk when start docker and copy data from docker into the local disk.



          such as:



          $ docker run --it -rm -v /your_path:/your_path  your_image
          # cp -rf /opencv /your_path
          # exit


          Then create your new docker, and copy the data from the local.






          share|improve this answer
























          • I was thinking about that as a workaround and I might just adopt that since as I note in my update COPY -from looks dodgy.

            – Ken Y-N
            Nov 16 '18 at 2:15














          1












          1








          1







          First map your local disk when start docker and copy data from docker into the local disk.



          such as:



          $ docker run --it -rm -v /your_path:/your_path  your_image
          # cp -rf /opencv /your_path
          # exit


          Then create your new docker, and copy the data from the local.






          share|improve this answer













          First map your local disk when start docker and copy data from docker into the local disk.



          such as:



          $ docker run --it -rm -v /your_path:/your_path  your_image
          # cp -rf /opencv /your_path
          # exit


          Then create your new docker, and copy the data from the local.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 16 '18 at 2:14









          Kinght 金Kinght 金

          8,49031941




          8,49031941













          • I was thinking about that as a workaround and I might just adopt that since as I note in my update COPY -from looks dodgy.

            – Ken Y-N
            Nov 16 '18 at 2:15



















          • I was thinking about that as a workaround and I might just adopt that since as I note in my update COPY -from looks dodgy.

            – Ken Y-N
            Nov 16 '18 at 2:15

















          I was thinking about that as a workaround and I might just adopt that since as I note in my update COPY -from looks dodgy.

          – Ken Y-N
          Nov 16 '18 at 2:15





          I was thinking about that as a workaround and I might just adopt that since as I note in my update COPY -from looks dodgy.

          – Ken Y-N
          Nov 16 '18 at 2:15




















          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%2f53330437%2fcopying-built-opencv-from-one-docker-image-to-another%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