skip to Main Content

I’m doing this:

RUN export FOO=hello
RUN env

The second RUN doesn’t see the FOO environment variable. Is it a limitation of Docker?

If it is, how do I set PATH in one RUN and make it available in another RUN?

2

Answers


  1. The docker RUN command initializes its own shell when called in a new line. There is no connection between the two RUN commands.

    Bash commands, however, can be combined in a single RUN statement.

    RUN export FOO=hello 
        && env
    
    Login or Signup to reply.
  2. Why not use Dockerfile’s ENV instruction for this purpose?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search