Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Monitoring Docker

You're reading from   Monitoring Docker Monitor your Docker containers and their apps using various native and third-party tools with the help of this exclusive guide!

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher Packt
ISBN-13 9781785882753
Length 148 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Russ McKendrick Russ McKendrick
Author Profile Icon Russ McKendrick
Russ McKendrick
Arrow right icon
View More author details
Toc

Running a virtual server

In the repository, you will find two folders containing the necessary Vagrant file to launch either a CentOS 7 or a Ubuntu 14.04 virtual server.

If you would like to use the CentOS 7 vagrant box, change the directory to vagrant-centos:

cd vagrant-centos

Once you are in the vagrant-centos directory, you will see that there is a Vagrant file; this file is all you need to launch a CentOS 7 virtual server. After the virtual server has been booted, the latest version of docker and docker-compose will be installed and the monitoring-docker directory will also be mounted inside the virtual machine using the mount point /monitoring-docker.

To launch the virtual server, simply type the following command:

vagrant up

This will download the latest version of the vagrant box from https://atlas.hashicorp.com/russmckendrick/boxes/centos71 and then boot the virtual server; it's a 450 MB download so it may take several minutes to download; it only has to do this once.

If all goes well, you should see something similar to the following output:

Running a virtual server

Now that you have booted the virtual server, you can connect to it using the following command:

vagrant ssh

Once logged in, you should verify that docker and docker-compose are both available:

Running a virtual server

Finally, you can try running the hello-world container using the following command:

docker run hello-world

If everything goes as expected, you should see the following output:

Running a virtual server

To try something more ambitious, you can run an Ubuntu container with the following command:

docker run -it ubuntu bash

Before we launch and enter the Ubuntu container, lets confirm that we are running the CentOS host machine by checking the release file that can be found in /etc:

Running a virtual server

Now, we can launch the Ubuntu container. Using the same command, we can confirm that we are inside the Ubuntu container by viewing its release file:

Running a virtual server

To exit the container just type in exit. This will stop the container from running, as it has terminated the only running process within the container, which was bash, and returned you to the host CentOS machine.

As you can see here from our CentOS 7 host, we have launched and removed an Ubuntu container.

Both the CentOS 7 and Ubuntu Vagrant files will configure a static IP address on your virtual machine. It is 192.168.33.10; also, there is a DNS record for this IP address available at docker.media-glass.es. These will allow you to access any containers that expose themselves to a browser at either http://192.168.33.10/ or http://docker.media-glass.es/.

Tip

The URL http://docker.media-glass.es/ will only work while the vagrant box is up, and you have a container running which serves Web pages.

You can see this in action by running the following command:

docker run -d -p 80:80russmckendrick/nginx-php

Tip

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

This will download and launch a container running NGINX. You can then go to http://192.168.33.10/ or http://docker.media-glass.es/ in your browser; you should see a forbidden page. This is because we have not yet given NGINX any content to serve (more on this will be covered later in the book):

Running a virtual server

For more examples and ideas, go to the website at http://docs.docker.com/userguide/.

You have been reading a chapter from
Monitoring Docker
Published in: Dec 2015
Publisher: Packt
ISBN-13: 9781785882753
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image