Your api_image would need to be able to recognise the API_ENDPOINT variable and then know what to do with it - so unless your api_image has that function already, then you’ll need to create a custom image that does know what to do with the variable.
Docker-compose simply sets the environment variables in the container, so this works just the same as using environment variables with dotnet core without using docker…
Now, I haven’t seen app.config used for dotnet core, so maybe that’s your problem, I thought it was a dotnet framework thing… Usually in dotnet core config is taken from appsettings.json, and overridden using environment variables.
From code you can use dependency injection to get access the values through IConfiguration:
public class MyClass
{
private readonly IConfiguration _config:
public MyClass(IConfiguration config) => _config = config;
public SomeMethod()
{
var apiUrl = _config["API_ENDPOINT"];
}
}