¿Cómo escribir comandos con varias líneas en Dockerfile preservando las nuevas líneas?
Quiero escribir el siguiente comando RUN en el Dockerfile. Pero, docker no está preservando las nuevas líneas.
RUN echo "[repo] \
name = YUM Repository \
baseurl = https://example.com/packages/ \
enabled = 1 \
gpgcheck = 0" > /etc/yum.repos.d/Repo.repoxyz
Sé que \
al final de cada línea se escapa la nueva línea. Pero, ¿hay alguna manera de que pueda escribir varias líneas preservando la nueva línea?
27
Author: Benjamin W., 2015-10-30
2 answers
Comienza tu comando con $'
, termina con '
y usa \n\
para nuevas líneas, así:
RUN echo $'[repo] \n\
name = YUM Repository \n\
baseurl = https://example.com/packages/ \n\
enabled = 1 \n\
gpgcheck = 0' > /etc/yum.repos.d/Repo.repoxyz
46
Author: Daniel Zolnai,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-24 16:26:02
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-24 16:26:02
Usé printf
. Escribir todo el texto en una línea usando "\n".
Ejecutando:
RUN printf 'example \ntext \nhere' >> example.txt
Inserta:
example
text
here
En el ejemplo.txt
17
Author: CTodea,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-19 14:12:39
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-19 14:12:39