Answer the question
In order to leave comments, you need to log in
How to edit a file in a docker image before executing it?
Good day.
Task: edit the configuration file (replace with sed) before starting the container.
The bottom line: there is a docker image, which is an assembled angular application with a specific base-href. Image is universal and rolls out in a compartment with others using docker-compose, combining several UIs and a bunch of microservices for backing. Since the rollout takes place at different sites, it became necessary to roll it out with a different base-href from the options to simply rebuild the container for the site, but since this is not according to the canon, we decided to change the base-href in index.html before launching. That’s all, but I didn’t find anything except command for these purposes and the code began to look terrible
ui-app1:
image: harbor.example.local/project/gui/ui-app1:1.0.3
ports:
- "8981:80"
network_mode: "bridge"
command: >
sh -c "sed -i -E 's|/test/|/public/test/|' /usr/share/nginx/html/ui-app1/index.html &&
nginx -g 'daemon off;'"
volumes:
- type: bind
source: ./ui-app1/default-area1.conf
target: /etc/nginx/conf.d/default.conf
depends_on:
- haproxy
Answer the question
In order to leave comments, you need to log in
Well, it's really terrible, it's terrible when there are five lines of commands in the command.
In general, if the image is yours, then make a variable to make changes in it. If the image is not yours, then only with commands, you can still mount the script and execute it with the command.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question