is possible to link a DNS name to another DNS name in docker?

I’m kind of new on docker. I want to resolve DNS name into something define by the user. I mean, I have a service in docker which requires another service located in ‘myEndpoint’. I want to configure that when the service asked to ‘myEndpoint’ returns an IP/FQN I decide, either in the containers or outside.

How I can do this?

  • Undo docker-compose down
  • Docker log in command does not work
  • Can I store npm scripts outside of package.json, to avoid forcing Docker to refresh all modules on any npm script update?
  • Maven docker cache dependencies
  • The command '/bin/sh -c sudo pip3 install -r requirements.txt' returned a non-zero code: 1
  • docker push error “denied: requested access to the resource is denied”
  • How to expose host machine aliases to Docker container?
  • How to mount network Volume in Docker for Windows (Windows 10)
  • Docker “config” Container / Docker image
  • Docker load command replaces existing images with same name
  • How to create postgis extension for postgresql in docker?
  • Use consul to export IP and Port to another Docker container dynamically
  • One Solution collect form web for “is possible to link a DNS name to another DNS name in docker?”

    If you just want to map myEndpoing to a specific IP, you could use option --add-host when docker run ... your container. Take a look at the following example:

     ~/ docker run --add-host=myEndpoint:123.124.125.126 --rm alpine:3.3 ping myEndpoint -c 4
    PING myEndpoint (123.124.125.126): 56 data bytes
    64 bytes from 123.124.125.126: seq=0 ttl=37 time=0.522 ms
    64 bytes from 123.124.125.126: seq=1 ttl=37 time=0.391 ms
    64 bytes from 123.124.125.126: seq=2 ttl=37 time=2.161 ms
    64 bytes from 123.124.125.126: seq=3 ttl=37 time=0.488 ms
    
    --- myEndpoint ping statistics ---
    4 packets transmitted, 4 packets received, 0% packet loss
    round-trip min/avg/max = 0.391/0.890/2.161 ms
    

    You can refer to the docs of docker run for more details.

    But if you want to map myEndpoint to other domain name, I think you need to use a FQDN and configure it as a CNAME DNS record, then configure DNS server for your container with option --dns options when you do docker run .... Hope this could be helpful 🙂

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.