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_assigned 172.20.1.2 docker.dev.example.com
I have been trying commands such as: echo, printf, aux, sed, tee
This is what i unsuccessfully tried:
echo "\n" | docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' CONTAINER | echo " docker.dev.whip-around.com" | sudo tee -a /etc/hosts
Command to get container's IP works fine. I put it here as a reference only:
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' CONTAINER_NAME