Docker Community Forums

Share and learn in the Docker community.

Changing config files in app container

I’ve searched and found some information, but not sure what I’m looking at… (Yes another) new guy working with Docker containers. :slight_smile: I’ve recently set up a Bitnami Redmine 4.1.1 install on a Linux machine and it is working fine for the most part. Now I’m trying to tweak it and configure it to do the things I want. I worked with computers 25 years “back in the day” and I’m a document guy… I pore through the manuals and I read config files. The problem I’m having is every time I read about how to change this or that, it points me to /opt/bitnami or /etc/cron.daily or whatever… and it’s not there. I understand that what’s in the container is in the container and what is on the local host is on the host. I’ve learned how to use docker exec to get into the container, but I still usually can’t find what I need, or if I do, I don’t have vi or nano to change it and it won’t let me install it to do so. I’m kind of lost because I don’t know if I’m having a problem with Redmine being the latest version and the docs explaining something from an older version (some sections of the docs are a bit dated), I don’t know what I’m doing with Docker containers, or it’s the way Bitnami has the container set up and/or locked down. I’ve read through a bunch of posts here this morning and come to the conclusion that maybe what I want to do can be achieved with a bind mount just pointing to /. Would that allow me to edit anything I wanted to in the container? I realize I don’t want to go futzing around with the container setup as Bitnami configured it, but I have to be able to at least change the Redmine config files and rakefiles to be able to access email and the PostgreSQL files to setup backups. I’ve tried reading the Docker documentation, but even that typically points to something that’s not available on my machine or that doesn’t match up with what I’m seeing. If someone can at least point me in the right direction for some tutorials or something, I’d appreciate it. Thanks for your time!

Before try to enforce old patterns to the container world, you might want to look if this bitnami image provide environment variables for the required changes:
https://hub.docker.com/r/bitnami/redmine , scroll down to “Configuration”

I guess I could have used environment variables instead of editing the configuration.yml file to enable email notifications, but that doesn’t solve my problem. Thanks for pointing those out though.

Well then it seems there is no way arround having the configs outside the container and using a volume to mount them into the container.

Be aware if you bind-mount a host folder into a container folder (-v /path/on/host:/path/in/container) , the original content of the container folder will be invisible. If you use named volumes (-v namedvolume:/path/in/container), the container content is copied into the volume first time its used (though, not sure if this works for any container folder or only those declared as volume).

The funny part is, you can create a named volume backed by bind:

docker volume create \
  --driver local \
  -o o=bind \ 
  -o type=none \
  -o device=/path/on/host \
my_volume

Then use it with docker run -v my_volume:/path/in/container .... Sidenote: an existing volume declaration is immutable - if you need to change the configuration, you need to delete the old one and re-create the new one with the updated parameters. Only the declaration will be deleted - the files inside the “device” path remain untouched.

If using a named volume backed by bind, then you can still use docker cp containerid:/path/in/container /path/on/host to copy files/folder from the container to the host.

Do NOT try to edit files in the container. A container is disposable/ephemeral by design. Changes applied to container folders not mapped to a volume will be lost if the container is deleted.

First thing is to make sure you are using the right docs for the right version, otherwise you will be chasing your tail and it is not fun.
You can look for config files in the container, just create a session in the container and do a grep for those config files. You can copy those files to your host machine, modify them and then run the container again and mount them on top of those config files. This will cause the file in the container to be hidden by the mounted ones, as previously described by meyay. Use mounting if you are working locally or modify your setup to copy the files when the container is launched. You could create a Dockerfile where you use your image as base image and then copy the files. This approach would work for docker-compose as well.

But yeah, environmental variables is the way to go first… usually the image maintainer provides relevant instructions. Do you mind sharing the image you are using and referring to?

Related to your concern of a text editor…

docker run --rm -it alpine /bin/sh
vi /etc/hostname

You can use vi to edit your text. If you use the Dockerfile approach, you can also install other editors when building the image (emacs for example) and you can modify the files at your wish.

Yeah, that boat has sailed. Apparently when I started this journey, I completely misunderstood what Docker containers were and how they worked. I can’t speak for anyone else, but as for my situation, it would have been a LOT easier to start at square one with Docker, learn how to build my own image, set everything up how I wanted it and then deployed it in a container. Which is what I guess I’ll get started on this weekend. Kfrajer, I’m using bitnami/redmine:4 and bitnami/postgresql:11. I had it up and running in no time flat. Then I started trying to configure things, set up backups, etc and all hell broke loose. Thank you guys for your help!

You might want to take a look at this hightly recommended self paced Docker training. Many slides only take a couple of seconds to work through. This self paced training is better and way less time consuming than a
3 day docker trainings I had.

I’ll do that. I have to admit I fell victim to Docker and Bitnami’s claims of “ease of use”, etc, just loaded it up and started pulling images. I should have viewed the tutorials before I started pulling my hair out. :smiley: The upside is I have a working Redmine installation that is really helping me out and it wasn’t too hard to set up.

As long as you create a container using the way the image maintainer intended it, the claim is true. Though as soon as you want something else, you have to pay the price to actualy invest time to understand the mechanisms underneath.

All magic comes with a price :slight_smile:

Opening a shell and editing the httpd. conf file from the command line
Run the Apache web server container. …
Get the id of the running container. …
Open a shell in the running container. …
Check the current value of the LogLevel directive within the configuration file. …
Use sed to search and replace the line with what we want.

I agree. I found another user on Github whose documentation was a bit more thorough than Bitnami’s and between his readme file and the info you guys have given me, the light is coming on. Not knocking Bitnami’s work at all, I guess I just started at step 3 or 4 instead of step 1. :slight_smile: I haven’t had a chance to view the tutorial videos yet, because I’ve been up to my eyeballs, but will get to them by this weekend.

Lewis, I tried similar tactics originally, but lost my data a couple times before I put the brakes on. I’m going back to the beginner level before trying any more advanced techniques, but I appreciate your help!