Why my entrypoint script doesn't take effect of umask value while starting?











up vote
0
down vote

favorite












After creating container umask value is correct i.e 027 but while container is starting inside entrypoint it displays the 002 which was set inside /etc/profile



Dockerfle



FROM alpine:3.8
ENV ENV='/home/deploy/.profile'
RUN set -ex
&& addgroup -g 1000 deploy
&& adduser -D -u 1000 -G deploy -s /bin/sh deploy
&& echo "umask 027" > /home/deploy/.profile

USER deploy
.
.
.
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm7","-F"]


entrypoint.sh



#!/bin/sh
set -ax
umask # it outputs 022 which I expect to be 027
exec "$@"









share|improve this question




















  • 2




    /etc/profile and ~/.profile are only loaded when the shell is a login shell. Docker's RUN instruction spawns a non-login shell by default. No profile ⇒ no umask.
    – n.st
    Nov 25 at 22:02










  • But I have not set the umask value through RUN. It is inside /home/deploy/.profile . and the USER is deploy. So you mean when entrypoint script gets executed while starting the container it is not a login shell. Please correct me if I am wrong.Thanks.
    – SkyRar
    Nov 25 at 22:42










  • Sorry, I meant to type CMD instead of RUN. Based on the documentation, when Docker reaches your CMD ["php-fpm7","-F"], it runs the entrypoint with the CMD as arguments like this: sh -c /entrypoint.sh php-fpm7 -F. Since sh (which should be ash on Alpine) isn't started as a login shell, it does not look at /home/deploy/.profile and the umask stays unchanged.
    – n.st
    Nov 25 at 22:57










  • This is all conjecture based on the documentation, as I don't have a Docker installation to test this on at the moment. To test it for yourself, you could modify your entrypoint.sh to output whether it's running in a login or non-login shell, though.
    – n.st
    Nov 25 at 22:59










  • Thanks I got it. Can you give me some pointers how can I run the entrypoint script as a login shell ? Is ENTRYPOINT ["sh","-l","-c"] okay ?
    – SkyRar
    Nov 25 at 23:22

















up vote
0
down vote

favorite












After creating container umask value is correct i.e 027 but while container is starting inside entrypoint it displays the 002 which was set inside /etc/profile



Dockerfle



FROM alpine:3.8
ENV ENV='/home/deploy/.profile'
RUN set -ex
&& addgroup -g 1000 deploy
&& adduser -D -u 1000 -G deploy -s /bin/sh deploy
&& echo "umask 027" > /home/deploy/.profile

USER deploy
.
.
.
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm7","-F"]


entrypoint.sh



#!/bin/sh
set -ax
umask # it outputs 022 which I expect to be 027
exec "$@"









share|improve this question




















  • 2




    /etc/profile and ~/.profile are only loaded when the shell is a login shell. Docker's RUN instruction spawns a non-login shell by default. No profile ⇒ no umask.
    – n.st
    Nov 25 at 22:02










  • But I have not set the umask value through RUN. It is inside /home/deploy/.profile . and the USER is deploy. So you mean when entrypoint script gets executed while starting the container it is not a login shell. Please correct me if I am wrong.Thanks.
    – SkyRar
    Nov 25 at 22:42










  • Sorry, I meant to type CMD instead of RUN. Based on the documentation, when Docker reaches your CMD ["php-fpm7","-F"], it runs the entrypoint with the CMD as arguments like this: sh -c /entrypoint.sh php-fpm7 -F. Since sh (which should be ash on Alpine) isn't started as a login shell, it does not look at /home/deploy/.profile and the umask stays unchanged.
    – n.st
    Nov 25 at 22:57










  • This is all conjecture based on the documentation, as I don't have a Docker installation to test this on at the moment. To test it for yourself, you could modify your entrypoint.sh to output whether it's running in a login or non-login shell, though.
    – n.st
    Nov 25 at 22:59










  • Thanks I got it. Can you give me some pointers how can I run the entrypoint script as a login shell ? Is ENTRYPOINT ["sh","-l","-c"] okay ?
    – SkyRar
    Nov 25 at 23:22















up vote
0
down vote

favorite









up vote
0
down vote

favorite











After creating container umask value is correct i.e 027 but while container is starting inside entrypoint it displays the 002 which was set inside /etc/profile



Dockerfle



FROM alpine:3.8
ENV ENV='/home/deploy/.profile'
RUN set -ex
&& addgroup -g 1000 deploy
&& adduser -D -u 1000 -G deploy -s /bin/sh deploy
&& echo "umask 027" > /home/deploy/.profile

USER deploy
.
.
.
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm7","-F"]


entrypoint.sh



#!/bin/sh
set -ax
umask # it outputs 022 which I expect to be 027
exec "$@"









share|improve this question















After creating container umask value is correct i.e 027 but while container is starting inside entrypoint it displays the 002 which was set inside /etc/profile



Dockerfle



FROM alpine:3.8
ENV ENV='/home/deploy/.profile'
RUN set -ex
&& addgroup -g 1000 deploy
&& adduser -D -u 1000 -G deploy -s /bin/sh deploy
&& echo "umask 027" > /home/deploy/.profile

USER deploy
.
.
.
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm7","-F"]


entrypoint.sh



#!/bin/sh
set -ax
umask # it outputs 022 which I expect to be 027
exec "$@"






docker alpine-linux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 at 21:32

























asked Nov 25 at 20:59









SkyRar

99




99








  • 2




    /etc/profile and ~/.profile are only loaded when the shell is a login shell. Docker's RUN instruction spawns a non-login shell by default. No profile ⇒ no umask.
    – n.st
    Nov 25 at 22:02










  • But I have not set the umask value through RUN. It is inside /home/deploy/.profile . and the USER is deploy. So you mean when entrypoint script gets executed while starting the container it is not a login shell. Please correct me if I am wrong.Thanks.
    – SkyRar
    Nov 25 at 22:42










  • Sorry, I meant to type CMD instead of RUN. Based on the documentation, when Docker reaches your CMD ["php-fpm7","-F"], it runs the entrypoint with the CMD as arguments like this: sh -c /entrypoint.sh php-fpm7 -F. Since sh (which should be ash on Alpine) isn't started as a login shell, it does not look at /home/deploy/.profile and the umask stays unchanged.
    – n.st
    Nov 25 at 22:57










  • This is all conjecture based on the documentation, as I don't have a Docker installation to test this on at the moment. To test it for yourself, you could modify your entrypoint.sh to output whether it's running in a login or non-login shell, though.
    – n.st
    Nov 25 at 22:59










  • Thanks I got it. Can you give me some pointers how can I run the entrypoint script as a login shell ? Is ENTRYPOINT ["sh","-l","-c"] okay ?
    – SkyRar
    Nov 25 at 23:22
















  • 2




    /etc/profile and ~/.profile are only loaded when the shell is a login shell. Docker's RUN instruction spawns a non-login shell by default. No profile ⇒ no umask.
    – n.st
    Nov 25 at 22:02










  • But I have not set the umask value through RUN. It is inside /home/deploy/.profile . and the USER is deploy. So you mean when entrypoint script gets executed while starting the container it is not a login shell. Please correct me if I am wrong.Thanks.
    – SkyRar
    Nov 25 at 22:42










  • Sorry, I meant to type CMD instead of RUN. Based on the documentation, when Docker reaches your CMD ["php-fpm7","-F"], it runs the entrypoint with the CMD as arguments like this: sh -c /entrypoint.sh php-fpm7 -F. Since sh (which should be ash on Alpine) isn't started as a login shell, it does not look at /home/deploy/.profile and the umask stays unchanged.
    – n.st
    Nov 25 at 22:57










  • This is all conjecture based on the documentation, as I don't have a Docker installation to test this on at the moment. To test it for yourself, you could modify your entrypoint.sh to output whether it's running in a login or non-login shell, though.
    – n.st
    Nov 25 at 22:59










  • Thanks I got it. Can you give me some pointers how can I run the entrypoint script as a login shell ? Is ENTRYPOINT ["sh","-l","-c"] okay ?
    – SkyRar
    Nov 25 at 23:22










2




2




/etc/profile and ~/.profile are only loaded when the shell is a login shell. Docker's RUN instruction spawns a non-login shell by default. No profile ⇒ no umask.
– n.st
Nov 25 at 22:02




/etc/profile and ~/.profile are only loaded when the shell is a login shell. Docker's RUN instruction spawns a non-login shell by default. No profile ⇒ no umask.
– n.st
Nov 25 at 22:02












But I have not set the umask value through RUN. It is inside /home/deploy/.profile . and the USER is deploy. So you mean when entrypoint script gets executed while starting the container it is not a login shell. Please correct me if I am wrong.Thanks.
– SkyRar
Nov 25 at 22:42




But I have not set the umask value through RUN. It is inside /home/deploy/.profile . and the USER is deploy. So you mean when entrypoint script gets executed while starting the container it is not a login shell. Please correct me if I am wrong.Thanks.
– SkyRar
Nov 25 at 22:42












Sorry, I meant to type CMD instead of RUN. Based on the documentation, when Docker reaches your CMD ["php-fpm7","-F"], it runs the entrypoint with the CMD as arguments like this: sh -c /entrypoint.sh php-fpm7 -F. Since sh (which should be ash on Alpine) isn't started as a login shell, it does not look at /home/deploy/.profile and the umask stays unchanged.
– n.st
Nov 25 at 22:57




Sorry, I meant to type CMD instead of RUN. Based on the documentation, when Docker reaches your CMD ["php-fpm7","-F"], it runs the entrypoint with the CMD as arguments like this: sh -c /entrypoint.sh php-fpm7 -F. Since sh (which should be ash on Alpine) isn't started as a login shell, it does not look at /home/deploy/.profile and the umask stays unchanged.
– n.st
Nov 25 at 22:57












This is all conjecture based on the documentation, as I don't have a Docker installation to test this on at the moment. To test it for yourself, you could modify your entrypoint.sh to output whether it's running in a login or non-login shell, though.
– n.st
Nov 25 at 22:59




This is all conjecture based on the documentation, as I don't have a Docker installation to test this on at the moment. To test it for yourself, you could modify your entrypoint.sh to output whether it's running in a login or non-login shell, though.
– n.st
Nov 25 at 22:59












Thanks I got it. Can you give me some pointers how can I run the entrypoint script as a login shell ? Is ENTRYPOINT ["sh","-l","-c"] okay ?
– SkyRar
Nov 25 at 23:22






Thanks I got it. Can you give me some pointers how can I run the entrypoint script as a login shell ? Is ENTRYPOINT ["sh","-l","-c"] okay ?
– SkyRar
Nov 25 at 23:22

















active

oldest

votes











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%2f484089%2fwhy-my-entrypoint-script-doesnt-take-effect-of-umask-value-while-starting%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux 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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2funix.stackexchange.com%2fquestions%2f484089%2fwhy-my-entrypoint-script-doesnt-take-effect-of-umask-value-while-starting%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