D
D
Denis Kuznetsov2021-04-27 11:27:40
Java
Denis Kuznetsov, 2021-04-27 11:27:40

How to configure a program in a container outside?

Hello, let's say I have a spring application that I placed in a container and it has a config file property or yaml. I want to run this application in a docker container, but I need it to be configured externally. That is, each machine that will run has its own config, which lies somewhere on it. Help me figure out how to do this please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2021-04-27
@DennisKingsman

Good afternoon!
In fact, there are many options and the answers can be easily found if you search.
Here are a few:
Let's say you're building an image using a Dockerfile. If you want to be able to configure the process of creating an image based on a Dockerfile, then look at instructions such as ARG & ENV. ARG - allows you to define arguments at the stage (before creation) image. ENV - environment defines environment variables.
Accordingly, you can pass these parameters like this:
1) In the case of ARG for docker, use --build-args. In case of ENV use -e
2) In case of using docker-compose to pass parameter to Dockerfile use environment:
For example,

environment:
  - BASE_URL=http://example.com

3) If you want to pass the configuration for application.properties or application.yml from the outside, for example, from docker-compose, then you can simply specify the necessary configs in the environment.
For example,
environment:
      - spring.application.name=custom_app

Add. info:
https://stackoverflow.com/questions/46057625/exter...
https://stackoverflow.com/questions/58695423/pass-...
https://medium.com/@cybourgeoisie/docker-env- metho...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question