Environment variables passed to launch docker

I have an image of a docker that is partially ready for work. For it to work fully, I need to run

sudo docker run -d -p 80 --name myimage -e ADMIN_USER="user1" -e ADMIN_PASSWORD='password1' leonixyz/myimage:1.0

When I first run the image, my code sets up the application inside.

This is convenient, because every time I need a new instance of the application that needs to be configured for a different user each time, I can pass different environment variables to docker runand my code will configure the container specifically for the new user.

Unfortunately, I see that these variables cannot be removed from the container.

If I do:

sudo docker exec -it <container_id> bash

then I see the variables ADMIN_USERand ADMIN_PASSWORD(obviously) is still there.

I tried unset ADMIN_PASSWORDat the end of my one-time configuration code, but it does not work.

unset ADMIN_PASSWORD bash .

, ?


, , , https://github.com/docker/docker/issues/13490#issuecomment-162125128.

+5
3

? , , :

    ENTRYPOINT export ADMIN_USER="user1" \
               && export ADMIN_PASSWORD='password1' \
               && entrypoint.sh

script.

0

If you need to set env var (for whatever reason), it is described in the recommendations of Dockerfile .

FROM alpine
RUN export ADMIN_USER="mark" \
    && echo $ADMIN_USER > ./mark \
    && unset ADMIN_USER
CMD sh
0
source

Source: https://habr.com/ru/post/1654594/


All Articles