Connecting to the HTTP service

In the preceding section, indecently, from the warning message, we find out that the IP address of the container is 172.17.0.13. On a fully configured HTTP server container, no such warning is available, so let's still run the docker inspect subcommand to retrieve the IP address using the container ID:

$ sudo docker inspect 
--format='{{.NetworkSettings.IPAddress}}'
9d4d3566e55c0b8829086e9be2040751017989a47b5411c9c4f170ab865afcef

172.17.0.13

Having found the IP address of the container as 172.17.0.13, let's quickly run a web request on this IP address from the shell prompt of the Docker host, using the wget command. Here, we choose to run the wget command with -qO - in order to run in the quiet mode and also display the retrieved HTML file on the screen:

$ wget -qO - 172.17.0.13

Here, we are showcasing just the first five lines of the retrieved HTML file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
Modified from the Debian original for Ubuntu
Last updated: 2014-03-19

Awesome, isn't it? We got our first service running in a container, and we are able to reach out to our service from our Docker host.

Furthermore, on a plain vanilla Docker installation, the service offered by one container is accessible by any other container within the Docker host. You can go ahead, launch a new Ubuntu container in the interactive mode, install the wget package using apt-get, and run the same wget -qO - 172.17.0.13 command, as we did in the Docker host. Of course, you will see the same output.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset