0

I am new to docker compose and can’t figure out how to customize my images from private/public docker hub, before it starts with compose.

The final purpose is to have standard images on hub, which are called by compose and customize on the fly with one configuration file stored locally (containing password, IP, private info).

In more detail, I got a DB postgres, and a backend(django app) linked to it.

  • The DB need few customizations (create DB, give perms) after the image (Postgres:lastest) is pulled.
  • The backend need a config file added to a repertory inside that container before the app could work.

Everything is working fine if I do step by step, get the images, run each one as container and add the customization. And finally run one last time the containers DB and backend with the link.

With compose, as the whole thing is ran all togever once, I can’t seem to be able to customize correctly the backend (copy one file) before the container ran and is linked to the db. I can run customization after docker compose up, but seems that it’s too late.

Anyone could give me a tip how to make it work? Or what's the best approach for this process.

Thank you for your precious help. Very good evening!

Regards, Greg.

1 Answer 1

1

The backend need a config file added to a repertory inside that container before the app could work.

Why don't you use VOLUME to mount that file to the container. Docker compose supports the volumes: as standard syntax.

Alternatively, you can locally build that image, with that file via Dockerfile and push that image to hub. Then you can directly use your image, as if you you are using the standard image.

Sign up to request clarification or add additional context in comments.

4 Comments

I use compose-volume to mount a temp directory and then copy that conf file to a folder in the container. I couldn't map directly that local folder because it seems that the target (containing other files) get destroy by my local folder when mapping. Or is there an option I didn't see?
As far as I know, while using VOLUME, if you specify the mount folder, it will replace the destination folder with the mount folder. However, if you specify the mount file, it will add the file to your destination folder. Haven't tried with Compose though. Hope this helps.
Thank you both for your help. It is working now I add a bad configuration file in the mount volume.
It working now with compose, Mounting configuration files with Volume, initialize all containers with one script. Thanks a lot and good day!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.