Docker on mac –add-hosts option isn't really adding the host

I have docker 1.12.3 running on macOS sierra.

I need my server to set serveral ips in the hosts file, and also set the containter hostname to resolve to 127.0.0.1.

  • Packer,Dockramp vs Dockerfile
  • How to ignore uploads folder to stop content being removed on docker server when new build is created
  • When does Docker write to iptables?
  • My docker was stuck by down whalesay, what should I do?
  • How to sync code between container and host using docker-compose?
  • specify ip address for docker for mac
  • I had the following command

    docker run -dit -p 8080:8080 --add-host someServer:192.168.1.1 --add-host myHostName:127.0.0.1 -h myHostName myImage
    

    So the hostname did changed to myHostName, and also added to the hosts file.
    However, it doesn’t do anything!. Trying to use it in my server, or even just do ping myHostName resolve in

    ping: unknown host
    

    From the documation it look like it should work, but it doesn’t. I really need it and I don’t have any more ideas how to solve it.

    Please help.

  • Pull a local image to run a pod in Kubernetes
  • Mount a volume in docker using nodejs on windows
  • Apache Mesos - Docker container
  • How do I run kurento in a docker container, with kurento hello world example on host machine
  • Datastore returns 503 when trying to access from a docker container
  • Build inside docker container in jenkins
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.