Why does chown not work in RUN command in Docker?Why is one not allowed to use a Boolean in a...

Can anybody explain why using multicolumn changes the width of the four-column tabular environment?

Is it feasible to get a hash collision for CRC32, MD-5 and SHA-1 on one file?

What is an internal dimension/glue/muglue?

On math looking obvious in retrospect

How to create events observer that only call when REST api dispatch events?

If "more guns less crime", how do gun advocates explain that the EU has less crime than the US?

Submitting a new paper just after another was accepted by the same journal

Is there any way to stop a user from creating executables and running them?

Is there a command to install basic applications on Ubuntu 16.04?

80's/90's superhero cartoon with a man on fire and a man who made ice runways like Frozone

How does "Te vas a cansar" mean "You're going to get tired"?

TEMPO: play a (mp3) sound in animated GIF/PDF/SVG

Does the Fireball spell damage objects?

How can God warn people of the upcoming rapture without disrupting society?

Can a PC use the Levitate spell to avoid movement speed reduction from exhaustion?

How can this older-style irrigation tee be replaced?

Is it okay for a ticket seller in the USA to refuse to give you your change, keep it for themselves and claim it's a tip?

How to remove ambiguity: "... lives in the city of H, the capital of the province of NS, WHERE the unemployment rate is ..."?

is this F 6'9 chord a figured bass or a chord extension?

Boss wants me to ignore a software license

Why is there a large performance impact when looping over an array over 240 elements?

How can I categorize files in a directory based on their content?

WhatsApp calls on an iPhone and "data" and "minutes"

Why are Gatwick's runways too close together?



Why does chown not work in RUN command in Docker?


Why is one not allowed to use a Boolean in a docker-compose.yml?How to populate docker volumes in a build step to be used by a different containerDocker: strategy-advise for a rookieDocker build not picking up built jar?How to deploy my Express/React app to server with docker-compose and DockerfilesDocker not exposing port on mojave macJenkins run build in docker on server (withDockerServer not working)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







3















I have the following docker-compose file:



version: '2'

networks:
default:
driver: bridge

services:

yii2-app:
build:
context: .
dockerfile: ./Dockerfile-app
ports:
- "80:80"
networks:
- default
depends_on:
- yii2-db
volumes:
- "./app:/var/www/app"
- "./nginx:/etc/nginx/sites-available"
...


Dockerfile-app:



FROM richarvey/nginx-php-fpm

ADD app /var/www/app

RUN rm -Rf /etc/nginx/sites-enabled/*

ADD nginx/site.conf /etc/nginx/sites-available/site.conf

RUN ln -s /etc/nginx/sites-available/site.conf /etc/nginx/sites-enabled/site.conf

RUN cd /var/www/app &&
composer install

RUN cd /var/www/app && chmod +x yii &&
cd web && mkdir -p uploads &&
cd /var/www && chown nginx:nginx -R app/


My last command RUN has no effect: chown does not set the nginx files owner. The folder "uploads" also is not created.



When I run docker-compose build --no-cache that step is passed:



Step 7/7 : RUN cd /var/www/app && chmod +x yii &&     cd web && mkdir -p uploads &&     cd /var/www && chown nginx:nginx -R app/
---> Running in 26a918bece47
Removing intermediate container 26a918bece47
---> 00db026a461c
Successfully built 00db026a461c
Successfully tagged passport-app_yii2-app:latest


However, when I run the workload in the "common" way using docker-compose up -d the change is not applied.



Why does my last RUN command not work?










share|improve this question









New contributor



Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • I think you could try to debug those statements by executing them one by one and see if there is an issue.

    – profesor79
    12 hours ago











  • @profesor79 It seems like in Docker I can not create file (folder, make chown) in /var/www/app, because it's volume.

    – Log
    12 hours ago


















3















I have the following docker-compose file:



version: '2'

networks:
default:
driver: bridge

services:

yii2-app:
build:
context: .
dockerfile: ./Dockerfile-app
ports:
- "80:80"
networks:
- default
depends_on:
- yii2-db
volumes:
- "./app:/var/www/app"
- "./nginx:/etc/nginx/sites-available"
...


Dockerfile-app:



FROM richarvey/nginx-php-fpm

ADD app /var/www/app

RUN rm -Rf /etc/nginx/sites-enabled/*

ADD nginx/site.conf /etc/nginx/sites-available/site.conf

RUN ln -s /etc/nginx/sites-available/site.conf /etc/nginx/sites-enabled/site.conf

RUN cd /var/www/app &&
composer install

RUN cd /var/www/app && chmod +x yii &&
cd web && mkdir -p uploads &&
cd /var/www && chown nginx:nginx -R app/


My last command RUN has no effect: chown does not set the nginx files owner. The folder "uploads" also is not created.



When I run docker-compose build --no-cache that step is passed:



Step 7/7 : RUN cd /var/www/app && chmod +x yii &&     cd web && mkdir -p uploads &&     cd /var/www && chown nginx:nginx -R app/
---> Running in 26a918bece47
Removing intermediate container 26a918bece47
---> 00db026a461c
Successfully built 00db026a461c
Successfully tagged passport-app_yii2-app:latest


However, when I run the workload in the "common" way using docker-compose up -d the change is not applied.



Why does my last RUN command not work?










share|improve this question









New contributor



Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • I think you could try to debug those statements by executing them one by one and see if there is an issue.

    – profesor79
    12 hours ago











  • @profesor79 It seems like in Docker I can not create file (folder, make chown) in /var/www/app, because it's volume.

    – Log
    12 hours ago














3












3








3


1






I have the following docker-compose file:



version: '2'

networks:
default:
driver: bridge

services:

yii2-app:
build:
context: .
dockerfile: ./Dockerfile-app
ports:
- "80:80"
networks:
- default
depends_on:
- yii2-db
volumes:
- "./app:/var/www/app"
- "./nginx:/etc/nginx/sites-available"
...


Dockerfile-app:



FROM richarvey/nginx-php-fpm

ADD app /var/www/app

RUN rm -Rf /etc/nginx/sites-enabled/*

ADD nginx/site.conf /etc/nginx/sites-available/site.conf

RUN ln -s /etc/nginx/sites-available/site.conf /etc/nginx/sites-enabled/site.conf

RUN cd /var/www/app &&
composer install

RUN cd /var/www/app && chmod +x yii &&
cd web && mkdir -p uploads &&
cd /var/www && chown nginx:nginx -R app/


My last command RUN has no effect: chown does not set the nginx files owner. The folder "uploads" also is not created.



When I run docker-compose build --no-cache that step is passed:



Step 7/7 : RUN cd /var/www/app && chmod +x yii &&     cd web && mkdir -p uploads &&     cd /var/www && chown nginx:nginx -R app/
---> Running in 26a918bece47
Removing intermediate container 26a918bece47
---> 00db026a461c
Successfully built 00db026a461c
Successfully tagged passport-app_yii2-app:latest


However, when I run the workload in the "common" way using docker-compose up -d the change is not applied.



Why does my last RUN command not work?










share|improve this question









New contributor



Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have the following docker-compose file:



version: '2'

networks:
default:
driver: bridge

services:

yii2-app:
build:
context: .
dockerfile: ./Dockerfile-app
ports:
- "80:80"
networks:
- default
depends_on:
- yii2-db
volumes:
- "./app:/var/www/app"
- "./nginx:/etc/nginx/sites-available"
...


Dockerfile-app:



FROM richarvey/nginx-php-fpm

ADD app /var/www/app

RUN rm -Rf /etc/nginx/sites-enabled/*

ADD nginx/site.conf /etc/nginx/sites-available/site.conf

RUN ln -s /etc/nginx/sites-available/site.conf /etc/nginx/sites-enabled/site.conf

RUN cd /var/www/app &&
composer install

RUN cd /var/www/app && chmod +x yii &&
cd web && mkdir -p uploads &&
cd /var/www && chown nginx:nginx -R app/


My last command RUN has no effect: chown does not set the nginx files owner. The folder "uploads" also is not created.



When I run docker-compose build --no-cache that step is passed:



Step 7/7 : RUN cd /var/www/app && chmod +x yii &&     cd web && mkdir -p uploads &&     cd /var/www && chown nginx:nginx -R app/
---> Running in 26a918bece47
Removing intermediate container 26a918bece47
---> 00db026a461c
Successfully built 00db026a461c
Successfully tagged passport-app_yii2-app:latest


However, when I run the workload in the "common" way using docker-compose up -d the change is not applied.



Why does my last RUN command not work?







docker docker-compose






share|improve this question









New contributor



Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 5 hours ago









Pierre.Vriens

3,7613 gold badges17 silver badges54 bronze badges




3,7613 gold badges17 silver badges54 bronze badges






New contributor



Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 14 hours ago









LogLog

664 bronze badges




664 bronze badges




New contributor



Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • I think you could try to debug those statements by executing them one by one and see if there is an issue.

    – profesor79
    12 hours ago











  • @profesor79 It seems like in Docker I can not create file (folder, make chown) in /var/www/app, because it's volume.

    – Log
    12 hours ago



















  • I think you could try to debug those statements by executing them one by one and see if there is an issue.

    – profesor79
    12 hours ago











  • @profesor79 It seems like in Docker I can not create file (folder, make chown) in /var/www/app, because it's volume.

    – Log
    12 hours ago

















I think you could try to debug those statements by executing them one by one and see if there is an issue.

– profesor79
12 hours ago





I think you could try to debug those statements by executing them one by one and see if there is an issue.

– profesor79
12 hours ago













@profesor79 It seems like in Docker I can not create file (folder, make chown) in /var/www/app, because it's volume.

– Log
12 hours ago





@profesor79 It seems like in Docker I can not create file (folder, make chown) in /var/www/app, because it's volume.

– Log
12 hours ago










1 Answer
1






active

oldest

votes


















5














I found the reason of the problem.
In Docker "anything after the VOLUME instruction in a Dockerfile will not be able to make changes to that volume".
I define volume "./app:/var/www/app", and after that manipulate with it, so it's not work.






share|improve this answer








New contributor



Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "674"
    };
    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: 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
    });


    }
    });






    Log is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdevops.stackexchange.com%2fquestions%2f8872%2fwhy-does-chown-not-work-in-run-command-in-docker%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









    5














    I found the reason of the problem.
    In Docker "anything after the VOLUME instruction in a Dockerfile will not be able to make changes to that volume".
    I define volume "./app:/var/www/app", and after that manipulate with it, so it's not work.






    share|improve this answer








    New contributor



    Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.


























      5














      I found the reason of the problem.
      In Docker "anything after the VOLUME instruction in a Dockerfile will not be able to make changes to that volume".
      I define volume "./app:/var/www/app", and after that manipulate with it, so it's not work.






      share|improve this answer








      New contributor



      Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























        5












        5








        5







        I found the reason of the problem.
        In Docker "anything after the VOLUME instruction in a Dockerfile will not be able to make changes to that volume".
        I define volume "./app:/var/www/app", and after that manipulate with it, so it's not work.






        share|improve this answer








        New contributor



        Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        I found the reason of the problem.
        In Docker "anything after the VOLUME instruction in a Dockerfile will not be able to make changes to that volume".
        I define volume "./app:/var/www/app", and after that manipulate with it, so it's not work.







        share|improve this answer








        New contributor



        Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        share|improve this answer



        share|improve this answer






        New contributor



        Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        answered 12 hours ago









        LogLog

        664 bronze badges




        664 bronze badges




        New contributor



        Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




        New contributor




        Log is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.



























            Log is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Log is a new contributor. Be nice, and check out our Code of Conduct.













            Log is a new contributor. Be nice, and check out our Code of Conduct.












            Log is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to DevOps Stack Exchange!


            • 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%2fdevops.stackexchange.com%2fquestions%2f8872%2fwhy-does-chown-not-work-in-run-command-in-docker%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

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...