Docker build error: “could not connect to server” (behind proxy)












0















Context:
OS: Windows 10 Pro; Docker ver: 18.09.0 (build 4d60db4); Behind corporate proxy, using CNTLM to solve this issue. (currently pulling / running image works fine)



Problem:
I was trying to build the following Dockerfile:



FROM alpine:3.5
RUN apk add --update
python3
RUN pip3 install bottle
EXPOSE 8000
COPY main.py /main.py
CMD python3 /main.py


This is what I got:



Sending build context to Docker daemon  11.26kB
Step 1/6 : FROM alpine:3.5
---> dc496f71dbb5
Step 2/6 : RUN apk add --update python3
---> Running in 7f5099b20192
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/main: could not connect to server (check repositories file)
WARNING: Ignoring APKINDEX.c51f8f92.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/community: could not connect to server (check repositories file)
WARNING: Ignoring APKINDEX.d09172fd.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
python3 (missing):
required by: world[python3]
The command '/bin/sh -c apk add --update python3' returned a non-zero code: 1


I was able to access the URL from a browser, so there is no problem with the server itself.



I suspected that it has something to do with the proxy not being propagated to the container, as explained in this question, since I also did not get the http_proxy line when running docker run alpine env. However, after entering the proxies into the config file, it finally appeared. Yet the problem still exists.



I also tried to change the DNS as instructed here, but the problem is still unsolved.










share|improve this question



























    0















    Context:
    OS: Windows 10 Pro; Docker ver: 18.09.0 (build 4d60db4); Behind corporate proxy, using CNTLM to solve this issue. (currently pulling / running image works fine)



    Problem:
    I was trying to build the following Dockerfile:



    FROM alpine:3.5
    RUN apk add --update
    python3
    RUN pip3 install bottle
    EXPOSE 8000
    COPY main.py /main.py
    CMD python3 /main.py


    This is what I got:



    Sending build context to Docker daemon  11.26kB
    Step 1/6 : FROM alpine:3.5
    ---> dc496f71dbb5
    Step 2/6 : RUN apk add --update python3
    ---> Running in 7f5099b20192
    fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
    ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/main: could not connect to server (check repositories file)
    WARNING: Ignoring APKINDEX.c51f8f92.tar.gz: No such file or directory
    fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
    ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/community: could not connect to server (check repositories file)
    WARNING: Ignoring APKINDEX.d09172fd.tar.gz: No such file or directory
    ERROR: unsatisfiable constraints:
    python3 (missing):
    required by: world[python3]
    The command '/bin/sh -c apk add --update python3' returned a non-zero code: 1


    I was able to access the URL from a browser, so there is no problem with the server itself.



    I suspected that it has something to do with the proxy not being propagated to the container, as explained in this question, since I also did not get the http_proxy line when running docker run alpine env. However, after entering the proxies into the config file, it finally appeared. Yet the problem still exists.



    I also tried to change the DNS as instructed here, but the problem is still unsolved.










    share|improve this question

























      0












      0








      0








      Context:
      OS: Windows 10 Pro; Docker ver: 18.09.0 (build 4d60db4); Behind corporate proxy, using CNTLM to solve this issue. (currently pulling / running image works fine)



      Problem:
      I was trying to build the following Dockerfile:



      FROM alpine:3.5
      RUN apk add --update
      python3
      RUN pip3 install bottle
      EXPOSE 8000
      COPY main.py /main.py
      CMD python3 /main.py


      This is what I got:



      Sending build context to Docker daemon  11.26kB
      Step 1/6 : FROM alpine:3.5
      ---> dc496f71dbb5
      Step 2/6 : RUN apk add --update python3
      ---> Running in 7f5099b20192
      fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
      ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/main: could not connect to server (check repositories file)
      WARNING: Ignoring APKINDEX.c51f8f92.tar.gz: No such file or directory
      fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
      ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/community: could not connect to server (check repositories file)
      WARNING: Ignoring APKINDEX.d09172fd.tar.gz: No such file or directory
      ERROR: unsatisfiable constraints:
      python3 (missing):
      required by: world[python3]
      The command '/bin/sh -c apk add --update python3' returned a non-zero code: 1


      I was able to access the URL from a browser, so there is no problem with the server itself.



      I suspected that it has something to do with the proxy not being propagated to the container, as explained in this question, since I also did not get the http_proxy line when running docker run alpine env. However, after entering the proxies into the config file, it finally appeared. Yet the problem still exists.



      I also tried to change the DNS as instructed here, but the problem is still unsolved.










      share|improve this question














      Context:
      OS: Windows 10 Pro; Docker ver: 18.09.0 (build 4d60db4); Behind corporate proxy, using CNTLM to solve this issue. (currently pulling / running image works fine)



      Problem:
      I was trying to build the following Dockerfile:



      FROM alpine:3.5
      RUN apk add --update
      python3
      RUN pip3 install bottle
      EXPOSE 8000
      COPY main.py /main.py
      CMD python3 /main.py


      This is what I got:



      Sending build context to Docker daemon  11.26kB
      Step 1/6 : FROM alpine:3.5
      ---> dc496f71dbb5
      Step 2/6 : RUN apk add --update python3
      ---> Running in 7f5099b20192
      fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
      ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/main: could not connect to server (check repositories file)
      WARNING: Ignoring APKINDEX.c51f8f92.tar.gz: No such file or directory
      fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
      ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/community: could not connect to server (check repositories file)
      WARNING: Ignoring APKINDEX.d09172fd.tar.gz: No such file or directory
      ERROR: unsatisfiable constraints:
      python3 (missing):
      required by: world[python3]
      The command '/bin/sh -c apk add --update python3' returned a non-zero code: 1


      I was able to access the URL from a browser, so there is no problem with the server itself.



      I suspected that it has something to do with the proxy not being propagated to the container, as explained in this question, since I also did not get the http_proxy line when running docker run alpine env. However, after entering the proxies into the config file, it finally appeared. Yet the problem still exists.



      I also tried to change the DNS as instructed here, but the problem is still unsolved.







      docker proxy dns alpine






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 28 '18 at 1:46









      Leonard ABLeonard AB

      10411




      10411
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I finally managed to solve this problem, and the culprit was my setting in the CNTLM.
          For a background story, please check this post.



          The root cause of this problem is that the docker container could not access the internet from inside the VM due to wrong IP setting inside the CNTLM.ini.



          Normally CNTLM listens to 127.0.0.1:3128 by default to forward the proxy. I followed the default, and thus set the proxy setting on Docker (for the daemon - through the GUI, and for the container - through config.json) is also set into that address and port. It turns out that this "localhost" does not apply to the VM where docker sits, since the VM has its own localhost. Long story short, the solution is to change that address into dockerNAT IP address (10.0.75.1:3128) in all of the following locations:





          • CNTLM.ini (on the Listen line. Actually if we use CNTLM for other purposes as well, it is possible to supply more than one Listen line)

          • Docker daemon's proxy (through the Docker setting GUI)


          • Docker container config.json (usually in C:ProgramDataDockerConfig), by adding the following lines:



            "proxies":
            {
            "default":
            {
            "httpProxy": "http://10.0.75.1:3128",
            "httpsProxy": "http://10.0.75.1:3128",
            "noProxy": <your no_proxy>
            }
            }



          also check these related posts:




          • Building a docker image for a node.js app fails behind proxy

          • Docker client ignores HTTP_PROXY envar and build args

          • Beginner having trouble with docker behind company proxy






          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%2f53510864%2fdocker-build-error-could-not-connect-to-server-behind-proxy%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














            I finally managed to solve this problem, and the culprit was my setting in the CNTLM.
            For a background story, please check this post.



            The root cause of this problem is that the docker container could not access the internet from inside the VM due to wrong IP setting inside the CNTLM.ini.



            Normally CNTLM listens to 127.0.0.1:3128 by default to forward the proxy. I followed the default, and thus set the proxy setting on Docker (for the daemon - through the GUI, and for the container - through config.json) is also set into that address and port. It turns out that this "localhost" does not apply to the VM where docker sits, since the VM has its own localhost. Long story short, the solution is to change that address into dockerNAT IP address (10.0.75.1:3128) in all of the following locations:





            • CNTLM.ini (on the Listen line. Actually if we use CNTLM for other purposes as well, it is possible to supply more than one Listen line)

            • Docker daemon's proxy (through the Docker setting GUI)


            • Docker container config.json (usually in C:ProgramDataDockerConfig), by adding the following lines:



              "proxies":
              {
              "default":
              {
              "httpProxy": "http://10.0.75.1:3128",
              "httpsProxy": "http://10.0.75.1:3128",
              "noProxy": <your no_proxy>
              }
              }



            also check these related posts:




            • Building a docker image for a node.js app fails behind proxy

            • Docker client ignores HTTP_PROXY envar and build args

            • Beginner having trouble with docker behind company proxy






            share|improve this answer






























              1














              I finally managed to solve this problem, and the culprit was my setting in the CNTLM.
              For a background story, please check this post.



              The root cause of this problem is that the docker container could not access the internet from inside the VM due to wrong IP setting inside the CNTLM.ini.



              Normally CNTLM listens to 127.0.0.1:3128 by default to forward the proxy. I followed the default, and thus set the proxy setting on Docker (for the daemon - through the GUI, and for the container - through config.json) is also set into that address and port. It turns out that this "localhost" does not apply to the VM where docker sits, since the VM has its own localhost. Long story short, the solution is to change that address into dockerNAT IP address (10.0.75.1:3128) in all of the following locations:





              • CNTLM.ini (on the Listen line. Actually if we use CNTLM for other purposes as well, it is possible to supply more than one Listen line)

              • Docker daemon's proxy (through the Docker setting GUI)


              • Docker container config.json (usually in C:ProgramDataDockerConfig), by adding the following lines:



                "proxies":
                {
                "default":
                {
                "httpProxy": "http://10.0.75.1:3128",
                "httpsProxy": "http://10.0.75.1:3128",
                "noProxy": <your no_proxy>
                }
                }



              also check these related posts:




              • Building a docker image for a node.js app fails behind proxy

              • Docker client ignores HTTP_PROXY envar and build args

              • Beginner having trouble with docker behind company proxy






              share|improve this answer




























                1












                1








                1







                I finally managed to solve this problem, and the culprit was my setting in the CNTLM.
                For a background story, please check this post.



                The root cause of this problem is that the docker container could not access the internet from inside the VM due to wrong IP setting inside the CNTLM.ini.



                Normally CNTLM listens to 127.0.0.1:3128 by default to forward the proxy. I followed the default, and thus set the proxy setting on Docker (for the daemon - through the GUI, and for the container - through config.json) is also set into that address and port. It turns out that this "localhost" does not apply to the VM where docker sits, since the VM has its own localhost. Long story short, the solution is to change that address into dockerNAT IP address (10.0.75.1:3128) in all of the following locations:





                • CNTLM.ini (on the Listen line. Actually if we use CNTLM for other purposes as well, it is possible to supply more than one Listen line)

                • Docker daemon's proxy (through the Docker setting GUI)


                • Docker container config.json (usually in C:ProgramDataDockerConfig), by adding the following lines:



                  "proxies":
                  {
                  "default":
                  {
                  "httpProxy": "http://10.0.75.1:3128",
                  "httpsProxy": "http://10.0.75.1:3128",
                  "noProxy": <your no_proxy>
                  }
                  }



                also check these related posts:




                • Building a docker image for a node.js app fails behind proxy

                • Docker client ignores HTTP_PROXY envar and build args

                • Beginner having trouble with docker behind company proxy






                share|improve this answer















                I finally managed to solve this problem, and the culprit was my setting in the CNTLM.
                For a background story, please check this post.



                The root cause of this problem is that the docker container could not access the internet from inside the VM due to wrong IP setting inside the CNTLM.ini.



                Normally CNTLM listens to 127.0.0.1:3128 by default to forward the proxy. I followed the default, and thus set the proxy setting on Docker (for the daemon - through the GUI, and for the container - through config.json) is also set into that address and port. It turns out that this "localhost" does not apply to the VM where docker sits, since the VM has its own localhost. Long story short, the solution is to change that address into dockerNAT IP address (10.0.75.1:3128) in all of the following locations:





                • CNTLM.ini (on the Listen line. Actually if we use CNTLM for other purposes as well, it is possible to supply more than one Listen line)

                • Docker daemon's proxy (through the Docker setting GUI)


                • Docker container config.json (usually in C:ProgramDataDockerConfig), by adding the following lines:



                  "proxies":
                  {
                  "default":
                  {
                  "httpProxy": "http://10.0.75.1:3128",
                  "httpsProxy": "http://10.0.75.1:3128",
                  "noProxy": <your no_proxy>
                  }
                  }



                also check these related posts:




                • Building a docker image for a node.js app fails behind proxy

                • Docker client ignores HTTP_PROXY envar and build args

                • Beginner having trouble with docker behind company proxy







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 18 '18 at 6:38

























                answered Nov 30 '18 at 4:53









                Leonard ABLeonard AB

                10411




                10411
































                    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%2f53510864%2fdocker-build-error-could-not-connect-to-server-behind-proxy%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

                    Lallio

                    Unable to find Lightning Node

                    Futebolista