hostname

How can I add hostnames to a container on the same docker network?

£可爱£侵袭症+ 提交于 2019-11-29 18:06:58
问题 Suppose I have a docker compose file with two containers. Both reference each other in their /etc/hosts file. Container A has a reference for container B and vice versa. And all of this happens automatically. Now I want to add one or more hostnames to B in A's hosts file. How can I go about doing this? Is there a special way I can achieve this in Docker Compose? Example: 172.0.10.166 service-b my-custom-hostname 回答1: Yes. In your compose file you can specify network aliases. services: db:

PHP can not resolve mysql container name under certain circumstances

三世轮回 提交于 2019-11-29 17:58:37
I have legacy PHP application. It used mysqli to make mysql things. So in config I have DSN string to connect to mysql service. Like that mysql://username:password@db_hostname/dbname Mysqli returns error Warning: mysqli::real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known But if I will try connect by hand using this mysqli::real_connect("db_hostname") It says Warning: mysqli::real_connect(): (HY000/1045): Access denied for user ''@'172.21.0.3' (using password: NO) real_connect("user@db_hostname") , real_connect("mysql:db_hostname") , real_connect("mysql:host

Get hostname from Rails controller

有些话、适合烂在心里 提交于 2019-11-29 15:54:00
问题 I am trying to get the hostname of the machine which a rails application is running on from the controller. What would be the best way to do this taking into account it should work on both windows and linux? 回答1: There's always: require 'socket' ... Socket.gethostname I've got no Windows box handy with which to test this, but the docs make no mention of it being *nix specific. Note: The require statement is not necessary for Rails 4, and probably other Rails versions as well. It is required

How To Resolve Network Host Names From IP Address

家住魔仙堡 提交于 2019-11-29 12:26:53
I am working on wifi based chat engine and I was able to retrieve the list of hosts connected to current wifi network by followin this link and now got list of devices with ip addresses but i need host name from the ip address and tried following InetAddress inetAddr; try { inetAddr = InetAddress.getByName(host.hostname); String hostname = inetAddr.getHostName(); String canonicalHostname = inetAddr.getCanonicalHostName(); holder.computerName.setText("Canonical : "+host.hostname); } catch (Exception e) { e.printStackTrace(); } Here the host name and canonical host name both are displaying ip

How to reach docker containers by name instead of IP address?

混江龙づ霸主 提交于 2019-11-29 10:39:35
问题 Is there a way I can reach my docker containers using names instead of ip addresses? I've heard of pipework and I've seen some dns and hostname type options for docker, but I still am unable to piece everything together. Thank you for your time. I'm not sure if this is helpful, but this is what I've done so far: installed docker container host using docker-machine and the vmwarevsphere driver started up all the services with docker-compose I can reach all of the services from any other

Setting the Hostname in IIS Bindings Breaks Website

こ雲淡風輕ζ 提交于 2019-11-29 07:34:12
问题 I just got a Windows Server 2008 VPS and I'm having trouble getting IIS7 setup. I created a new website in IIS with the path, ip address, and hostname (like 'www.nameofsite.com') and click OK. When I browse to the site it pulls up "http://www.nameofsite.com" in the browser and... nothing... IE cannot display this webpage. If I blank out the hostname in the bindings and click [Browse] it works fine (it takes me to http://10.10.2.92 - the computer's ip). So entering the hostname breaks the

How to get local host name in C# on a Windows 10 universal app

不羁的心 提交于 2019-11-29 07:02:48
string machineName = System.Environment.MachineName; This code doesn't work for me, error code 'Environment' does not contain a definition for 'MachineName' I'm using Visual Studio 2015 and Universal App with C# Please also list the namespace I need to use when you post an answer. You need to use NetworkInformation.GetHostNames . var hostNames = Windows.Networking.Connectivity.NetworkInformation.GetHostNames(); But note that this method will return multiple HostName s. In my case, it returns four HostName s of which DisplayName s are MyComputerName , MyComputerName.local plus two IP addresses.

python: check if a hostname is resolved

[亡魂溺海] 提交于 2019-11-29 01:18:10
How can I have a function in python that returns 1 if the a hostname resolves and 0 if a hostname does not. I couldn't find anything useful, any thoughts? Thanks, You can use socket.gethostbyname() for this: >>> import socket >>> socket.gethostbyname('google.com') '74.125.224.198' >>> socket.gethostbyname('foo') # no host 'foo' exists on the network Traceback (most recent call last): File "<stdin>", line 1, in <module> socket.gaierror: [Errno 8] nodename nor servname provided, or not known Your function might look like this: def hostname_resolves(hostname): try: socket.gethostbyname(hostname)

Node JS return hostname

你离开我真会死。 提交于 2019-11-29 00:57:18
I'm still learning Node JS and javascript and have an app. I have a configuration file where I need to grab the hostname of the server on Ubuntu 12.04 I tried something like: window.location.hostname But that did not work. Sample code below: exports.config = { app_name : [ window.location.hostname ] } If I use a string, it will load fine, but this is going to be managed through Github and needs to be differentiated when the app loads. John Smith According to the node.js documentation for the "os" module you need to load the "os" module, which has a hostname() function: var os = require("os");

What is the maximum length of a DNS name

心不动则不痛 提交于 2019-11-29 00:06:24
问题 I saw several mentions that the maximum string length of a DNS name (domain name) is 253 characters. Wikipedia seems to be referring this old blog post: https://en.wikipedia.org/wiki/Hostname http://blogs.msdn.com/b/oldnewthing/archive/2012/04/12/10292868.aspx On the other hand, if I understood the RFC, this article is wrong. DNS name maximum string length should be 250 ASCII characters instead of 253 based on the following byte sequence which as per RFC1035 is maxed to 255 bytes: To simplify