Closed ZEB1CLJ closed 3 months ago
Hello @ZEB1CLJ ,
I followed the steps as you suggested: I changed $JAVA_OPTS
in Dockerfile to something else and after running the runscript.sh
when running exec in the container the $JAVA_OPTS
is updated as expected. Did I miss something?
Hello!
Indeed, the thing works as you mentioned. However, I retested the example and saw that there actually is a problem with files not being updated after a COPY
instruction is re-executed during build. So the env vars were properly updated, but the files were not.
But I found out that the Jenkins Docker image defines an anonymous volume that gets mounted automatically when using docker compose up
. It turns out that docker compose up
preserves anonymous volumes when recreating containers, so that was why the file didn't change.
I finally figured out that using --renew-anon-volumes
does the trick.
Description
docker compose
recreates container with old (cached?) version of image, although I run it with both--force-recreate
and--build
arguments.I've noticed that the following changes to the
Dockerfile
have absolutely no effect on the recreated containers (i.e. the containers seem not to pick up the changes)>COPY
instructionENV
directiveAs others have previously stated (here: https://github.com/docker/compose/issues/4273), I have to manually remove the containers if I want docker compose to recreate them properly. (By the way: what exactly does
recreate
do? Does it delete the container or not?)Steps To Reproduce
The contents of the files that I use are fairly simple, so they are listed below:
runscript.sh
script. Image build should start and a container should be started too.jenkins-autoconfigured
container, echo an environment variable (e.g.:JAVA_OPTS
)JAVA_OPTS
(or the env var that you printed at step 2) to something elserunscript.sh
again. This will rebuild the image and "recreate" the container.docker exec
inside the recreatedjenkins-autoconfigured
and notice that the env varJAVA_OPTS
is the same, even if you have rebuilt the image using docker compose.docker run -ti
the rebuilt docker image and notice how theJAVA_OPTS
variable is the correct (modified) one.Dockerfile:
plugins.txt:
casc.yaml:
Dockercompose:
runscript.sh:
Compose Version
Docker Environment
Anything else?
No response