Hi,
I am trying to build a docker image for my application and then run it through docker-compose. I added some hostname mappings that only work on certain private network into the docker-compose file but I still cannot get those hostname be reachable.
I guess it is because extra_hosts modifies /etc/hosts in the container but seems that we have to update networking.extraHosts in nixos config.
This is the nix file that I used to build the image:
dockerTools.buildImage {
name = "myapp";
contents = [ myapp cacert ];
tag = tag;
created = "now";
config = {
Cmd = [ "${myapp}/bin/Main" ];
WorkingDir = "/app";
ExposedPorts = {
"8080/tcp" = {};
};
};
}
And this is my docker-compose.yml:
version: '3'
services:
myapp:
image: myapp
restart: always
extra_hosts:
- "host.a.com:1.2.3.4"
- "host.b.com:1.2.3.4"
ports:
- 8080:8080
depends_on:
- "database"