Adding an entry in hosts file

AI-generated summary

Adding an entry in hosts file

Netboy3 and exhuma are trying to add an entry in the hosts file of the mail-receiver container during install time using an entry in the YAML config. exhuma suggests using the --add-host argument, typically handled by Docker.

exhuma found that adding docker_args: "--add-host myhost:192.0.2.1" to the config file (e.g., containers/app.yml) is sufficient to achieve this. This change takes effect immediately after rebuild, and the process is resilient across host reboots.

I need to add an entry in the hosts file of the mail-receiver container. Is there any way to do it during install time using an entry in the YAML config. I’ve tried run: and exec: without success.

I’m currently faced with the same issue. I also tried to manually add a command to be executed in the config file without luck.

The hosts file is handled by docker, and typically you need to use --add-host to achieve this. I don’t yet know how to add this argument to the startup of the discourse container.

I found some references on the web that suggest to add the following to the config file (f.ex. containers/app.yml):

docker_args: "--add-host myhost:192.0.2.1"

edit: The text below is not correct. It was cause by an “out-of-disk-space” error during rebuild on my side. Adding the config option above to the config file is sufficient.

But this does not work immediately after rebuild. It seems that the startup that happens at the end of the rebuild does not take that option into account. ./launcher stop app does however.

To get this to work I had to follow this process:

  • Edit containers/app.yml and add the line above as a “top-/root-level” argument
  • Rebuild the container using ./launcher rebuild app
  • Destroy the default container that was started by the rebuild using ./launcher destroy app
  • Start a new container using ./launcher start app

This seems to be resilient across host reboots. I suspect that the reboot behaviour relies on docker in that the docker daemon simply starts all containers that were running during shutdown with the same config.