How to inspect a container's IP, obtain it and add it to /etc/hosts file with a local domain name resolution

前端 未结 1 1162
面向向阳花
面向向阳花 2021-01-27 22:47

I am working on Linux Ubuntu with docker containers and I want the following added to the last line of /etc/hosts in a new line:

IP_from_docker_container hostname_as

相关标签:
1条回答
  • 2021-01-27 23:38

    >> appends to a file, so you can try this:

    echo `docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' CONT_NAME` example.com >> /etc/hosts
    
    0 讨论(0)
提交回复
热议问题