0

I'm trying to deploy a custom image to an azure function and I have a requirement of modifying /etc/hosts file inside the container.

I've tried giving --add-host argument at the docker build stage but it doesn't help. And as it is an azure function, It'll run the docker run command by itself without manual intervention.

So, just wanted to know if there's a possibility of adding --add-host argument to docker run command through Azure function's configuration.

1 Answers1

0

I'm afraid it's impossible to add --add-host argument to the docker run command. That's the function runtime and it's deployed by the Azure platform. You cannot change any parameters in it.

If you want to modify the /etc/hosts file, there are two ways to do it as I know. One is that change it directly when you create the custom image. Another one is that enable the SSH server in the custom image and then change the /etc/hosts file when the function runs well from your custom image via the SSH connection.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
  • Thanks Charles for the response. I've tried doing it from within the image using CMD but the functionality is being modified as I have other RUN commands within the dockerfile. And, using the second approach it is working perfectly fine if I modify it from the SSH console of the functionapp – Spandana Soma Jun 25 '20 at 07:19
  • @SpandanaSoma If you have other RUN commands, you can do it at the end of the Dockerfile. And those are two possible ways ad I know. If the answer works for you, please accept it. – Charles Xu Jun 26 '20 at 01:07
  • @SpandanaSoma Any more questions? Do you solve the problem? – Charles Xu Jun 29 '20 at 02:01
  • @CharlesXu can you give example for the RUN commands approach. I am afraid I could not follow it properly – Nitin Agarwal Sep 28 '21 at 06:43