Add mapping ip and host into /etc/hosts with docker
You could try to use docker compose and the docker compose "extra_hosts" tag, as described on the docker compose specification at https://docs.docker.com/compose/compose-file/.


  extra_hosts
  
  Add hostname mappings. Use the same values as the docker client --add-host parameter.
  
  extra_hosts:
  
  
  "somehost:162.242.195.82"
  "otherhost:50.31.209.229"
  
  
  An entry with the ip address and hostname is created in /etc/hosts 
  for this service, e.g:
  
  162.242.195.82  somehost
  
  50.31.209.229   otherhostinside containers


So, this will mean, that you need to use docker compose in addition to docker.