Read Docker secret in docker-entrypoint












0















I can't read my Docker secrets trough my docker-entrypoint script. I added all my secrets in my docker service create command and each time my service crashing telling me the /run/secrets/<secret_name> is not existing.



Someone can tell me why ? And how I can read my secret ?



My docker_entrypoint :



#!/bin/bash

set -e

cp /run/secrets/configuration.py /opt/netbox/netbox/netbox/configuration.py
chmod +x /opt/netbox/netbox/netbox/configuration.py

DJANGO_USER="$(< /run/secrets/django_user)"
DJANGO_MAIL="$(< /run/secrets/django_mail)"
DJANGO_PASS="$(< /run/secrets/django_pass)"

cd /opt/netbox/netbox/
python3.6 manage.py migrate

echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('$DJANGO_USER', '$DJANGO_MAIL', '$DJANGO_PASS')" | python3.6 manage.py shell

python3.6 manage.py collectstatic --noinput

unset DJANGO_USER
unset DJANGO_MAIL
unset DJANGO_PASS

exec "$@"


The error:



/opt/netbox/entrypoint.sh: line 5: /run/secrets/configuration.py: No such file or directory









share|improve this question























  • The error simply states that there is no /run/secrets/configuration.py file. Maybe you forgot to add it to your container?

    – lependu
    Nov 15 '18 at 15:51











  • @lependu No it is, Because when I start my container without the entrypoint. I can read ̀/run/secrets/configuration.py` file.

    – DevHugo
    Nov 15 '18 at 15:56











  • Can you edit your post to show us how do you run your container without entrypoint?

    – lependu
    Nov 15 '18 at 15:58













  • do a ls /run/secrets/ to see if there is anything inside.

    – Siyu
    Nov 15 '18 at 16:40
















0















I can't read my Docker secrets trough my docker-entrypoint script. I added all my secrets in my docker service create command and each time my service crashing telling me the /run/secrets/<secret_name> is not existing.



Someone can tell me why ? And how I can read my secret ?



My docker_entrypoint :



#!/bin/bash

set -e

cp /run/secrets/configuration.py /opt/netbox/netbox/netbox/configuration.py
chmod +x /opt/netbox/netbox/netbox/configuration.py

DJANGO_USER="$(< /run/secrets/django_user)"
DJANGO_MAIL="$(< /run/secrets/django_mail)"
DJANGO_PASS="$(< /run/secrets/django_pass)"

cd /opt/netbox/netbox/
python3.6 manage.py migrate

echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('$DJANGO_USER', '$DJANGO_MAIL', '$DJANGO_PASS')" | python3.6 manage.py shell

python3.6 manage.py collectstatic --noinput

unset DJANGO_USER
unset DJANGO_MAIL
unset DJANGO_PASS

exec "$@"


The error:



/opt/netbox/entrypoint.sh: line 5: /run/secrets/configuration.py: No such file or directory









share|improve this question























  • The error simply states that there is no /run/secrets/configuration.py file. Maybe you forgot to add it to your container?

    – lependu
    Nov 15 '18 at 15:51











  • @lependu No it is, Because when I start my container without the entrypoint. I can read ̀/run/secrets/configuration.py` file.

    – DevHugo
    Nov 15 '18 at 15:56











  • Can you edit your post to show us how do you run your container without entrypoint?

    – lependu
    Nov 15 '18 at 15:58













  • do a ls /run/secrets/ to see if there is anything inside.

    – Siyu
    Nov 15 '18 at 16:40














0












0








0








I can't read my Docker secrets trough my docker-entrypoint script. I added all my secrets in my docker service create command and each time my service crashing telling me the /run/secrets/<secret_name> is not existing.



Someone can tell me why ? And how I can read my secret ?



My docker_entrypoint :



#!/bin/bash

set -e

cp /run/secrets/configuration.py /opt/netbox/netbox/netbox/configuration.py
chmod +x /opt/netbox/netbox/netbox/configuration.py

DJANGO_USER="$(< /run/secrets/django_user)"
DJANGO_MAIL="$(< /run/secrets/django_mail)"
DJANGO_PASS="$(< /run/secrets/django_pass)"

cd /opt/netbox/netbox/
python3.6 manage.py migrate

echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('$DJANGO_USER', '$DJANGO_MAIL', '$DJANGO_PASS')" | python3.6 manage.py shell

python3.6 manage.py collectstatic --noinput

unset DJANGO_USER
unset DJANGO_MAIL
unset DJANGO_PASS

exec "$@"


The error:



/opt/netbox/entrypoint.sh: line 5: /run/secrets/configuration.py: No such file or directory









share|improve this question














I can't read my Docker secrets trough my docker-entrypoint script. I added all my secrets in my docker service create command and each time my service crashing telling me the /run/secrets/<secret_name> is not existing.



Someone can tell me why ? And how I can read my secret ?



My docker_entrypoint :



#!/bin/bash

set -e

cp /run/secrets/configuration.py /opt/netbox/netbox/netbox/configuration.py
chmod +x /opt/netbox/netbox/netbox/configuration.py

DJANGO_USER="$(< /run/secrets/django_user)"
DJANGO_MAIL="$(< /run/secrets/django_mail)"
DJANGO_PASS="$(< /run/secrets/django_pass)"

cd /opt/netbox/netbox/
python3.6 manage.py migrate

echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('$DJANGO_USER', '$DJANGO_MAIL', '$DJANGO_PASS')" | python3.6 manage.py shell

python3.6 manage.py collectstatic --noinput

unset DJANGO_USER
unset DJANGO_MAIL
unset DJANGO_PASS

exec "$@"


The error:



/opt/netbox/entrypoint.sh: line 5: /run/secrets/configuration.py: No such file or directory






docker dockerfile docker-swarm






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 15:47









DevHugoDevHugo

6410




6410













  • The error simply states that there is no /run/secrets/configuration.py file. Maybe you forgot to add it to your container?

    – lependu
    Nov 15 '18 at 15:51











  • @lependu No it is, Because when I start my container without the entrypoint. I can read ̀/run/secrets/configuration.py` file.

    – DevHugo
    Nov 15 '18 at 15:56











  • Can you edit your post to show us how do you run your container without entrypoint?

    – lependu
    Nov 15 '18 at 15:58













  • do a ls /run/secrets/ to see if there is anything inside.

    – Siyu
    Nov 15 '18 at 16:40



















  • The error simply states that there is no /run/secrets/configuration.py file. Maybe you forgot to add it to your container?

    – lependu
    Nov 15 '18 at 15:51











  • @lependu No it is, Because when I start my container without the entrypoint. I can read ̀/run/secrets/configuration.py` file.

    – DevHugo
    Nov 15 '18 at 15:56











  • Can you edit your post to show us how do you run your container without entrypoint?

    – lependu
    Nov 15 '18 at 15:58













  • do a ls /run/secrets/ to see if there is anything inside.

    – Siyu
    Nov 15 '18 at 16:40

















The error simply states that there is no /run/secrets/configuration.py file. Maybe you forgot to add it to your container?

– lependu
Nov 15 '18 at 15:51





The error simply states that there is no /run/secrets/configuration.py file. Maybe you forgot to add it to your container?

– lependu
Nov 15 '18 at 15:51













@lependu No it is, Because when I start my container without the entrypoint. I can read ̀/run/secrets/configuration.py` file.

– DevHugo
Nov 15 '18 at 15:56





@lependu No it is, Because when I start my container without the entrypoint. I can read ̀/run/secrets/configuration.py` file.

– DevHugo
Nov 15 '18 at 15:56













Can you edit your post to show us how do you run your container without entrypoint?

– lependu
Nov 15 '18 at 15:58







Can you edit your post to show us how do you run your container without entrypoint?

– lependu
Nov 15 '18 at 15:58















do a ls /run/secrets/ to see if there is anything inside.

– Siyu
Nov 15 '18 at 16:40





do a ls /run/secrets/ to see if there is anything inside.

– Siyu
Nov 15 '18 at 16:40












0






active

oldest

votes











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%2f53323074%2fread-docker-secret-in-docker-entrypoint%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f53323074%2fread-docker-secret-in-docker-entrypoint%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

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python