I
I
Igor2016-05-02 11:58:36
linux
Igor, 2016-05-02 11:58:36

Docker. Why does the environment variable disappear when switching to another user?

1st container sets PATH variable for docker user

FROM ubuntu:15.10
USER root
RUN groupadd -r docker && useradd -r -g docker docker
USER docker
ENV PATH /hello-world:$PATH

2nd container
FROM step_1
USER root

When I go to the second container and switch to the docker user, the PATH variable is reset. If in the second container I do not switch to the root user, then the variable is saved.
Why is this happening? How do I save the PATH variable for all docker users?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-05-02
@sterjakov

When I go into the second container and switch to the docker user, the PATH variable is reset

Well, you changed the "environment" in fact. The only way to avoid this is to write it to /etc/environment.
In general, it will be easier to just put your binary in /usr/local/bin for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question