When I run the following docker-compose file, the containers are able to connect to each other by using their hostnames as mentioned in the docker-compose file. So container escher can connect to container boqs by doing http://boqs. I think this is because docker changes the internal host files, right? Now my question is: is it possible to do this also for a normal docker run command so that the host can connect to it by using this name??
So what I want:
start a container boqs
connect to it from the host machine by doing: http://boqs (on the same way docker-compose makes this work)
Unfortunately that does not work. I want to run a container and give it a --name, f.e. “redis”. Then I want to connect to that container from the host itself, by connecting to the hostname provided in the --name command.
on the default bridge network there’s no name resolution, to have the same behavior as provided by docker-compose, you must create a network and connect your containers on this network
Thanks; but this is also not what I want, because you’re talking about linking two running containers.
I just want to connect on the host machine to a container (running on that host machine) by connecting to the “name” I used while running the container.