Docker run SED command before container starts

I’m running Rundeck with docker-compose and Dockerfile and i need to modify a value inside a file which is inside the container.

I can copy the modified file from another place (local) and place it inside the container while the build phase is in process but somehow the file gets replaced by the original one and that aproach doesn’t work.

I’ve also tried to run SED command (so i can modify the exact line of the file) inside Dockerfile but again that doesn’t work and the container shows the original file with nothing modified inside.

So, I known that the image is innmutable and cannot be modified (also is not a good practise).

What can I do here?. What is the best approach to every time I run a new Rundeck image apply that modification I need within the file?.

Replication escenario: Dockerfile

FROM rundeck/rundeck:4.2.3-rc1-20220712    
WORKDIR /home/rundeck    
RUN sudo apt-get update
RUN sudo apt-get install nano

Docker-compose (be aware of yml format!)

version: '3.4'
services:
rundeck:
    restart: always
    build: .
    container_name: rundeck
    links:
      - mysql
    tty: true
    ports:
      - 4444:4440
    environment:
        RUNDECK_GRAILS_URL: http://192.168.1.5:4444
        RUNDECK_SERVER_FORWARDED: 'true'
        RUNDECK_DATABASE_DRIVER: org.mariadb.jdbc.Driver
        RUNDECK_DATABASE_USERNAME: rundeck
        RUNDECK_DATABASE_PASSWORD: rundeck
        RUNDECK_LOGLEVEL_DEFAULT: info
        RUNDECK_DATABASE_URL: jdbc:mysql://mysql/rundeck?autoReconnect=true&useSSL=false             
    volumes:
      -  /run/docker.sock:/var/run/docker.sock
      -  /home/ubuntu/.ssh:/home/rundeck/.ssh
      - ./rundeck_data:/home/rundeck/server/data
      - ./rundeck_config:/home/rundeck/server/config

Once the container is up, look up the file located at /home/rundeck/server/config “rundeck-config.properties” inside the container. On line 42 i need to change value 30d (actual) by 0d.

Any help will be really aprecciated!.

Regards!

Hi

Have you seen if the variable you want to change, is listed here?

Also you’re right regarding it being overwritten, as you can see in the original dockerfile.

1 Like

Hi!

Is not listed, i’ve previously checked that. If so, i can pass it as ENV on the docker-compose, but unlucky is not listed.

Regards!

which variable are you interested in?

Beware, @terpz, this was also posted on Docker run SED command before container starts - Server Fault, and it seems it has an answer that satisfies the OP.

Thanks :smiley:

I came to the same conclusion but wasnt sure about the variable :wink:

Thanks a lot everyone, i could find the solution here Docker run SED command before container starts - Server Fault.

Thanks you all!.

Regards.