![]() ![]() ![]() In both cases, your containerized service will be using that custom address ( wso2-api in my example) and (since that hostname will be included in the container's /etc/hosts file) that custom hostname will properly resolve to the actual ip-address that you need. With the IP of the Docker Host (directly inside your docker0 network)ĭocker run -it -add-host=wso2-api:$DOCKER_HOST_IP consumer/service.With the IP of your actual Host (using -net=host)ĭocker run -it -net=host -add-host=wso2-api:$YOUR-HOST-IP consumer/service.You can achieve this by including an extra host to the container with the -add-host parameter, in one of two possible ways (to your convenience): ![]() If the port that you bind to the docker service is exactly 80 ( -p 80:80) then you can even use only the custom domain (with no port at all) your-custom-domainįor the use case when you want your containerized services to be able to access to another service running (externally) in your host, but with a custom hostname instead of the ip of "localhost" (with or without the -net=host): after appending your localhost alias with your custom local domain, you can access your nginx service (in the example above) by hitting: your-custom-domain:8080 This will allow you to use your 8080 port to access the 80 port of the service running inside your container. When you start your container, you can bind a port in your host to any port of your dockerized service that you need to access from outside: docker run -name nginx -p 8080:80 nginx Then just go to your browser and go directly to that address, with the port that you should have already been sharing in your docker containerĮxplaining a bit more the thing about the docker port: If that part is what you're actually looking for, you can achieve it easily by adding an entry to your /etc/hosts file, right there together with the one for localhost (which is an "alias" of your 127.0.01) 127.0.0.1 localhost ![]() I need to use a name instead of my IP or localhost ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |