Hi, I’ve got a problem with a mariadb container on balena.
I’m trying to overwrite the custom.cnf file located in the container in /etc/mysql/conf.d via Dockerfile command COPY custom.cnf /etc/mysql/conf.d/ (the custom.cnf file in my directory is right next to the Dockerfile), but the file in the container remains the same.
Hello Krestin,
I tested overwriting in Dockerfile just now. If you want to overwrite the custom.cnffile in your container, the COPYcommand destination path needs to be absolute. Hence, it should be something like COPY custom.cnf /etc/mysql/conf.d/custom.cnf. Do try it out and let us know if it works out for you. Thanks!
Hi there, can you share your Dockerfile snippet (the part where you make the overwrite)? please redact any sensitive info, I just want to make sure the commands and their ordering is correct
Hello, the file you are trying to COPY should be available in the context you are passing to docker build In the compose snippet above I see context: ./webmacs.mysql so that should be the only file available for the build. If that file is just next to the dockerfile something like context: . should work fine.
Hi, webmacs.mysql
is the folder under my docker-compose-file, where the Dockerfile and the custom.cnf I want to copy are located. So it should be able to find the custom.cnf there, right?
To clarify a bit further on my colleague’s answer, since you are specifically defining a context that does not include the file you wish to copy, Docker won’t be able to find that file. If you alter your docker-compose.yml to instead pass a context of context: ., Docker will see both your subdirectory called webmacs.mysql as well as your custom.cnf. We wrote a masterclass covering some of the commonly-used Dockerfile directives that might help explain that further, feel free to give that a read as well: https://www.balena.io/docs/learn/more/masterclasses/docker-masterclass/#42-copy-directive
Hi,
I’m still not sure I get the problem.
I added the line COPY custom.cnf /etc/test/custom.cnf
to the Dockerfile right before the line where I want to COPY it to the actual directory (COPY custom.cnf /etc/mysql/conf.d/custom.cnf).
The custom.cnf file then ends up in /etc/test/ so Docker is actually able to find the file and context should not be the issue,right? Or do I still miss the point?
I think the confusion here is that ./webmacs.mysql sounds like a file rather than a folder. Can you confirm that this is actually a folder and within this folder is your docker file as well as the custom.cnf file?
Hey @kerstin_boergers it might be best to perhaps push your code up to github or somewhere to share with us as we can get a better sense of how things are laid out in your repo and reproduce it our side.
I looked into it and I think I would start by simplifying your compose file build section. I built the image directly in docker and it copied the config without issue. So try this:
I would suggest first confirming that the path /etc/mysql/conf.d/custom.cnf is the right one?
It seems like the image you are using expects db settings to be in /config