Docker for Developers by Chris Tankersley

Docker for Developers by Chris Tankersley

Author:Chris Tankersley
Language: eng
Format: epub, mobi
Publisher: leanpub.com
Published: 2015-12-09T16:00:00+00:00


Well, that run command is a doozy. We’re going to create a container that runs in the background named app_nginx. This container will mount the volumes from app_php inside of itself, much like we did before with the data containers. We’re also going to mount a config file inside of it, which contains our configuration so we can have nginx talk to the php-fpm process that lives inside app_php. That is all pretty standard from the stuff I have gone over so far.

What is new is the --link [name]:[alias] option. This tells Docker to link the named container to the container you are creating, with the alias you specify. In this case, we are linking the app_php container with the name of phpserver. Inside the nginx container, we can use phpserver as the domain name for our PHP container!

If I grab the IP address for my app_nginx container using docker inspect, I can visit that IP and be greeted with a basic PHP info screen, like in Figure 3-1.

Figure 3-1 Linking containers together has a nice side effect in newer versions of Docker, at least since v1.9. Docker will now track the IP correctly when linked containers come up and down. For example, if you have the above nginx and PHP containers, and turn PHP on and off, PHP will more than likely get a new IP. This IP will be given to the nginx container automatically. Older versions of Docker set the IP staticly when the container was built, so if PHP was at 10.10.0.2 when nginx came up, nginx would think PHP was at that IP until the nginx container was restarted.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.