Docker-compose: cannot build WITHOUT sudo but I can run containers without it











up vote
1
down vote

favorite












Over my ubuntu GNU/Linux machine I try to build the images from my project



docker-compose build --no-cache --force-rm


And I get the following error:



ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.


But when I try wiuth sudo I can build them:



sudo docker-compose build --no-cache --force-rm


But I find it somewhat mysterious because I can launch them without the need of sudo:



docker-compose up









share|improve this question




























    up vote
    1
    down vote

    favorite












    Over my ubuntu GNU/Linux machine I try to build the images from my project



    docker-compose build --no-cache --force-rm


    And I get the following error:



    ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

    If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.


    But when I try wiuth sudo I can build them:



    sudo docker-compose build --no-cache --force-rm


    But I find it somewhat mysterious because I can launch them without the need of sudo:



    docker-compose up









    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Over my ubuntu GNU/Linux machine I try to build the images from my project



      docker-compose build --no-cache --force-rm


      And I get the following error:



      ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

      If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.


      But when I try wiuth sudo I can build them:



      sudo docker-compose build --no-cache --force-rm


      But I find it somewhat mysterious because I can launch them without the need of sudo:



      docker-compose up









      share|improve this question















      Over my ubuntu GNU/Linux machine I try to build the images from my project



      docker-compose build --no-cache --force-rm


      And I get the following error:



      ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

      If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.


      But when I try wiuth sudo I can build them:



      sudo docker-compose build --no-cache --force-rm


      But I find it somewhat mysterious because I can launch them without the need of sudo:



      docker-compose up






      linux ubuntu sudo docker






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago









      Rui F Ribeiro

      38.2k1475125




      38.2k1475125










      asked Dec 25 '17 at 20:02









      Dimitrios Desyllas

      16315




      16315






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          The cause of the problem is that you have a volume mount point with root:root owner & group and caused this behavior.



          The solution to this problem is to create a file named .dockerignore and put all the folders mounted as volumes.



          For example if you have the following docker-compose.yml



          version: '2'
          services:
          data_map_prod:
          build:
          context: .
          dockerfile: Dockerfile
          image: 'pcmagas/data-map:latest'
          links:
          - 'neo4j'
          - 'mongodb'
          volumes:
          - './docker-volumes/app_dev:/var/log/datamap'
          ports:
          - "9780:9780"
          environment:
          NEO4J_HOST: 'neo4j'
          MONGO_CONNECTION_STRING: 'mongodb://mongodb:map'

          data_map_dev:
          build:
          context: .
          dockerfile: Dockerfile_dev
          image: 'pcmagas/data-map:dev'
          links:
          - 'neo4j_dev'
          - 'mongodb'
          volumes:
          - './src:/opt/map/src'
          - './www:/opt/map/www'
          - './package.json:/opt/map/package.json'
          - './docker-volumes/app_dev:/var/log/datamap'
          ports:
          - "9781:9780"
          environment:
          NEO4J_HOST: 'neo4j_dev'
          NEO4J_USER: 'neo4j'
          NEO4J_PASSWORD: 'neo4j'
          MONGO_CONNECTION_STRING: 'mongodb://mongodb:map_dev'

          neo4j_dev:
          image: 'neo4j'
          ports:
          - '7474:7474'
          volumes:
          - './docker-volumes/neo4j_dev/data:/data'
          environment:
          NEO4J_AUTH: 'neo4j/neo45j'

          neo4j:
          image: 'neo4j'
          volumes:
          - './docker-volumes/neo4j/data:/data'
          environment:
          NEO4J_AUTH: 'neo4j/neo45j'

          mongodb:
          image: 'mongo'
          ports:
          - '27017:27017'
          volumes:
          - './docker-volumes/mongodb/:/data/db'


          Then you should create the following .dockerignore:



          ./docker-volumes


          As you can see all the volumes are in ./docker-volumes folder.



          Furtermore you can find solutions in: https://stackoverflow.com/questions/29101043/cant-connect-to-docker-from-docker-compose#29111083






          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: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2funix.stackexchange.com%2fquestions%2f413015%2fdocker-compose-cannot-build-without-sudo-but-i-can-run-containers-without-it%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








            up vote
            1
            down vote



            accepted










            The cause of the problem is that you have a volume mount point with root:root owner & group and caused this behavior.



            The solution to this problem is to create a file named .dockerignore and put all the folders mounted as volumes.



            For example if you have the following docker-compose.yml



            version: '2'
            services:
            data_map_prod:
            build:
            context: .
            dockerfile: Dockerfile
            image: 'pcmagas/data-map:latest'
            links:
            - 'neo4j'
            - 'mongodb'
            volumes:
            - './docker-volumes/app_dev:/var/log/datamap'
            ports:
            - "9780:9780"
            environment:
            NEO4J_HOST: 'neo4j'
            MONGO_CONNECTION_STRING: 'mongodb://mongodb:map'

            data_map_dev:
            build:
            context: .
            dockerfile: Dockerfile_dev
            image: 'pcmagas/data-map:dev'
            links:
            - 'neo4j_dev'
            - 'mongodb'
            volumes:
            - './src:/opt/map/src'
            - './www:/opt/map/www'
            - './package.json:/opt/map/package.json'
            - './docker-volumes/app_dev:/var/log/datamap'
            ports:
            - "9781:9780"
            environment:
            NEO4J_HOST: 'neo4j_dev'
            NEO4J_USER: 'neo4j'
            NEO4J_PASSWORD: 'neo4j'
            MONGO_CONNECTION_STRING: 'mongodb://mongodb:map_dev'

            neo4j_dev:
            image: 'neo4j'
            ports:
            - '7474:7474'
            volumes:
            - './docker-volumes/neo4j_dev/data:/data'
            environment:
            NEO4J_AUTH: 'neo4j/neo45j'

            neo4j:
            image: 'neo4j'
            volumes:
            - './docker-volumes/neo4j/data:/data'
            environment:
            NEO4J_AUTH: 'neo4j/neo45j'

            mongodb:
            image: 'mongo'
            ports:
            - '27017:27017'
            volumes:
            - './docker-volumes/mongodb/:/data/db'


            Then you should create the following .dockerignore:



            ./docker-volumes


            As you can see all the volumes are in ./docker-volumes folder.



            Furtermore you can find solutions in: https://stackoverflow.com/questions/29101043/cant-connect-to-docker-from-docker-compose#29111083






            share|improve this answer



























              up vote
              1
              down vote



              accepted










              The cause of the problem is that you have a volume mount point with root:root owner & group and caused this behavior.



              The solution to this problem is to create a file named .dockerignore and put all the folders mounted as volumes.



              For example if you have the following docker-compose.yml



              version: '2'
              services:
              data_map_prod:
              build:
              context: .
              dockerfile: Dockerfile
              image: 'pcmagas/data-map:latest'
              links:
              - 'neo4j'
              - 'mongodb'
              volumes:
              - './docker-volumes/app_dev:/var/log/datamap'
              ports:
              - "9780:9780"
              environment:
              NEO4J_HOST: 'neo4j'
              MONGO_CONNECTION_STRING: 'mongodb://mongodb:map'

              data_map_dev:
              build:
              context: .
              dockerfile: Dockerfile_dev
              image: 'pcmagas/data-map:dev'
              links:
              - 'neo4j_dev'
              - 'mongodb'
              volumes:
              - './src:/opt/map/src'
              - './www:/opt/map/www'
              - './package.json:/opt/map/package.json'
              - './docker-volumes/app_dev:/var/log/datamap'
              ports:
              - "9781:9780"
              environment:
              NEO4J_HOST: 'neo4j_dev'
              NEO4J_USER: 'neo4j'
              NEO4J_PASSWORD: 'neo4j'
              MONGO_CONNECTION_STRING: 'mongodb://mongodb:map_dev'

              neo4j_dev:
              image: 'neo4j'
              ports:
              - '7474:7474'
              volumes:
              - './docker-volumes/neo4j_dev/data:/data'
              environment:
              NEO4J_AUTH: 'neo4j/neo45j'

              neo4j:
              image: 'neo4j'
              volumes:
              - './docker-volumes/neo4j/data:/data'
              environment:
              NEO4J_AUTH: 'neo4j/neo45j'

              mongodb:
              image: 'mongo'
              ports:
              - '27017:27017'
              volumes:
              - './docker-volumes/mongodb/:/data/db'


              Then you should create the following .dockerignore:



              ./docker-volumes


              As you can see all the volumes are in ./docker-volumes folder.



              Furtermore you can find solutions in: https://stackoverflow.com/questions/29101043/cant-connect-to-docker-from-docker-compose#29111083






              share|improve this answer

























                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                The cause of the problem is that you have a volume mount point with root:root owner & group and caused this behavior.



                The solution to this problem is to create a file named .dockerignore and put all the folders mounted as volumes.



                For example if you have the following docker-compose.yml



                version: '2'
                services:
                data_map_prod:
                build:
                context: .
                dockerfile: Dockerfile
                image: 'pcmagas/data-map:latest'
                links:
                - 'neo4j'
                - 'mongodb'
                volumes:
                - './docker-volumes/app_dev:/var/log/datamap'
                ports:
                - "9780:9780"
                environment:
                NEO4J_HOST: 'neo4j'
                MONGO_CONNECTION_STRING: 'mongodb://mongodb:map'

                data_map_dev:
                build:
                context: .
                dockerfile: Dockerfile_dev
                image: 'pcmagas/data-map:dev'
                links:
                - 'neo4j_dev'
                - 'mongodb'
                volumes:
                - './src:/opt/map/src'
                - './www:/opt/map/www'
                - './package.json:/opt/map/package.json'
                - './docker-volumes/app_dev:/var/log/datamap'
                ports:
                - "9781:9780"
                environment:
                NEO4J_HOST: 'neo4j_dev'
                NEO4J_USER: 'neo4j'
                NEO4J_PASSWORD: 'neo4j'
                MONGO_CONNECTION_STRING: 'mongodb://mongodb:map_dev'

                neo4j_dev:
                image: 'neo4j'
                ports:
                - '7474:7474'
                volumes:
                - './docker-volumes/neo4j_dev/data:/data'
                environment:
                NEO4J_AUTH: 'neo4j/neo45j'

                neo4j:
                image: 'neo4j'
                volumes:
                - './docker-volumes/neo4j/data:/data'
                environment:
                NEO4J_AUTH: 'neo4j/neo45j'

                mongodb:
                image: 'mongo'
                ports:
                - '27017:27017'
                volumes:
                - './docker-volumes/mongodb/:/data/db'


                Then you should create the following .dockerignore:



                ./docker-volumes


                As you can see all the volumes are in ./docker-volumes folder.



                Furtermore you can find solutions in: https://stackoverflow.com/questions/29101043/cant-connect-to-docker-from-docker-compose#29111083






                share|improve this answer














                The cause of the problem is that you have a volume mount point with root:root owner & group and caused this behavior.



                The solution to this problem is to create a file named .dockerignore and put all the folders mounted as volumes.



                For example if you have the following docker-compose.yml



                version: '2'
                services:
                data_map_prod:
                build:
                context: .
                dockerfile: Dockerfile
                image: 'pcmagas/data-map:latest'
                links:
                - 'neo4j'
                - 'mongodb'
                volumes:
                - './docker-volumes/app_dev:/var/log/datamap'
                ports:
                - "9780:9780"
                environment:
                NEO4J_HOST: 'neo4j'
                MONGO_CONNECTION_STRING: 'mongodb://mongodb:map'

                data_map_dev:
                build:
                context: .
                dockerfile: Dockerfile_dev
                image: 'pcmagas/data-map:dev'
                links:
                - 'neo4j_dev'
                - 'mongodb'
                volumes:
                - './src:/opt/map/src'
                - './www:/opt/map/www'
                - './package.json:/opt/map/package.json'
                - './docker-volumes/app_dev:/var/log/datamap'
                ports:
                - "9781:9780"
                environment:
                NEO4J_HOST: 'neo4j_dev'
                NEO4J_USER: 'neo4j'
                NEO4J_PASSWORD: 'neo4j'
                MONGO_CONNECTION_STRING: 'mongodb://mongodb:map_dev'

                neo4j_dev:
                image: 'neo4j'
                ports:
                - '7474:7474'
                volumes:
                - './docker-volumes/neo4j_dev/data:/data'
                environment:
                NEO4J_AUTH: 'neo4j/neo45j'

                neo4j:
                image: 'neo4j'
                volumes:
                - './docker-volumes/neo4j/data:/data'
                environment:
                NEO4J_AUTH: 'neo4j/neo45j'

                mongodb:
                image: 'mongo'
                ports:
                - '27017:27017'
                volumes:
                - './docker-volumes/mongodb/:/data/db'


                Then you should create the following .dockerignore:



                ./docker-volumes


                As you can see all the volumes are in ./docker-volumes folder.



                Furtermore you can find solutions in: https://stackoverflow.com/questions/29101043/cant-connect-to-docker-from-docker-compose#29111083







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 26 '17 at 10:36

























                answered Dec 26 '17 at 10:15









                Dimitrios Desyllas

                16315




                16315






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f413015%2fdocker-compose-cannot-build-without-sudo-but-i-can-run-containers-without-it%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

                    Accessing regular linux commands in Huawei's Dopra Linux

                    Can't connect RFCOMM socket: Host is down

                    Kernel panic - not syncing: Fatal Exception in Interrupt