From Dockerfile you can use something like:
FROM image
ARG Match="kaps-service"
COPY file.txt /etc/
RUN sed -i 's/$Match/'$Match'/g' /etc/file.txt
The last line will replace all occurrences of $Match with "kaps-service". This will happen during build step, and you can modify Match argument with the --build-arg
flag
In case you want the replacement to be in run step (docker run) you can take the RUN command and put it in some script that will execute this command before your application. It can be something like:
FROM image
WORKDIR /app
ENV Match="kaps-service"
COPY file.txt /etc/
COPY run .
CMD "./run"
where run
is:
#!/bin/bash
sed -i 's/$Match/'$Match'/g' /etc/file.txt
# run you app
The change will happen when you starts a container with docker run
and you can modify Match variable add -e Match=something
to the command.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…