Dockerfile: Output of RUN instruction into a Variable

后端 未结 3 1702
南旧
南旧 2020-12-09 14:48

I am writing a dockerfile and want to put the output of the \"ls\" command into a variable as shown below:

$file = ls /tmp/dir

Here, \"dir\

3条回答
  •  再見小時候
    2020-12-09 14:56

    I couldn't get Andy's (or any other) approach to work in the Dockerfile itself, so I set my Dockerfile entrypoint to a bash file containing:

    #!/bin/bash
    file="$(conda list --explicit)" && echo $file
    echo $(conda list --explicit)
    

    Note the second method doesn't render line breaks, so I found the first method - echo via the $file variable - superior.

提交回复
热议问题