Код: Выделить всё
MYVAR=world
Код: Выделить всё
FROM redhat/ubi8
COPY script.sh /script.sh
# Source the script and echo. Expected to see: hello world
RUN source /script.sh && echo hello $MYVAR
# Run echo without sourcing script. Expected to see: hello
RUN echo hello $MYVAR
# Modify SHELL and echo. Expected to see: hello world
SHELL ["/bin/bash", "-c", "'source /script.sh'", "&&"]
RUN echo hello $MYVAR
Но при сборке я получаю следующую ошибку:
Код: Выделить всё
#9 [5/5] RUN echo hello $MYVAR
#9 0.194 &&: source /script.sh: No such file or directory
#9 ERROR: process "/bin/bash -c 'source /script.sh' && echo hello $MYVAR" did not complete successfully: exit code: 127
------
> [5/5] RUN echo hello $MYVAR:
0.194 &&: source /script.sh: No such file or directory
------
Dockerfile:12
--------------------
10 | SHELL ["/bin/bash", "-c", "'source /script.sh'", "&&"]
11 |
12 | >>> RUN echo hello $MYVAR
13 |
--------------------
ERROR: failed to solve: process "/bin/bash -c 'source /script.sh' && echo hello $MYVAR" did not complete successfully: exit code: 127
У этого кода выхода нет, но эхо ничего не отображает:
Код: Выделить всё
SHELL ["/bin/bash", "-c", "source /script.sh", "&&"]
Код: Выделить всё
SHELL ["/bin/bash", "-c", "\"source /script.sh\"", "&&"]
Код: Выделить всё
SHELL ["/bin/bash", "-c", "source /script.sh &&"]
Код: Выделить всё
SHELL ["/bin/bash", "-c", "'source /script.sh' &&"]
Код: Выделить всё
SHELL ["/bin/bash", "-c", "\"source /script.sh" &&"]
- Сборка Docker — используйте одну и ту же оболочку для всех команд RUN
- Запускать скрипт перед каждым запуском в Dockerfile?
Подробнее здесь: https://stackoverflow.com/questions/791 ... oesnt-work
Мобильная версия