table of contents - vmwaredocs.hol.vmware.com/hol-2014/hol-sdc-1430_pdf_en.pdf · docker basics in...

69
Table of Contents HOL-SDC-1430 - Docker Essentials for the vSphere Admin ............................................... 2 Lab Overview .......................................................................................................... 3 Module 1 - Hello PEX! (15 min) ......................................................................................... 4 Hello PEX! ............................................................................................................... 5 Module 2 - Feel the Pain - (45 min) ................................................................................. 11 Over the Wall ........................................................................................................ 12 Module 3 - Hello Docker! - (30 min) ................................................................................ 19 Docker Basics ........................................................................................................ 20 Testing Code with Docker ...................................................................................... 27 Docker and VMware - Better Together! ................................................................. 31 Module 4 - The Missing Piece - (60 min).......................................................................... 38 DevOps Automation with VMware ......................................................................... 39 How it works (one way!)........................................................................................ 41 Module 5 - DevOps Nirvana - (15 min) ............................................................................ 52 The whole picture.................................................................................................. 53 Summary .............................................................................................................. 68 HOL-SDC-1430 Page 1 HOL-SDC-1430

Upload: others

Post on 05-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Table of ContentsHOL-SDC-1430 - Docker Essentials for the vSphere Admin............................................... 2

Lab Overview .......................................................................................................... 3Module 1 - Hello PEX! (15 min) ......................................................................................... 4

Hello PEX! ............................................................................................................... 5Module 2 - Feel the Pain - (45 min) ................................................................................. 11

Over the Wall ........................................................................................................ 12Module 3 - Hello Docker! - (30 min) ................................................................................ 19

Docker Basics........................................................................................................ 20Testing Code with Docker...................................................................................... 27Docker and VMware - Better Together! ................................................................. 31

Module 4 - The Missing Piece - (60 min).......................................................................... 38DevOps Automation with VMware......................................................................... 39How it works (one way!)........................................................................................ 41

Module 5 - DevOps Nirvana - (15 min) ............................................................................ 52The whole picture.................................................................................................. 53Summary .............................................................................................................. 68

HOL-SDC-1430

Page 1HOL-SDC-1430

Page 2: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

HOL-SDC-1430 - DockerEssentials for thevSphere Admin

HOL-SDC-1430

Page 2HOL-SDC-1430

Page 3: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Lab OverviewIn this lab, you will modify a very simple "Hello World" application and test it. Followinga successful test on your local machine, you will push the code to Git.

You will then send the code over the wall to the Ops team. The Ops team will attempt torun your code in an environment with little in the way of automated processes. The goalhere will be to identify some of the difficulties developers and operations teams may runinto without adequate communication and tooling.

In the third Module of the lab, you will be introduced to Docker and the effects this hason how developers push their code to various locations.

In Module 4, you will examine how automation and coordination between the Dev andOps teams allows for a seamless transition of code from various stages to production-like deployments. This is the missing piece of the puzzle!

In Module 5, you will execute a deployment and visualize the end results of all your hardwork!

HOL-SDC-1430

Page 3HOL-SDC-1430

Page 4: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Module 1 - Hello PEX! (15min)

HOL-SDC-1430

Page 4HOL-SDC-1430

Page 5: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Hello PEX!In this Module, you play the role of a developer deploying a simple Hello Worldapplication. Because of the manner in which Hands-On Labs are setup, you will need toremote into the Linux desktop which is the developer's "environment", if you will.

Launch VNC

From the ControlCenter desktop:

1. Double-click the tightvnc shortcut.2. The information should be pre-populated. Simply click Connect.3. A password prompt will appear. Input VMware1!4. Click Login.

HOL-SDC-1430

Page 5HOL-SDC-1430

Page 6: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Launch Geany

You are now in the Linux desktop of the developer.

1. Double-click the text-editor Geany.

HOL-SDC-1430

Page 6HOL-SDC-1430

Page 7: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Change the Code

You will see some code immediately. This is your extremely simple HelloWorldapplication.

1. Replace "HelloWorld" with "Welcome to HOL1430". Click File -> Save.2. Minimize the Geany editor. You may need to scroll over to see the minimize

button, depending on the resolution.

HOL-SDC-1430

Page 7HOL-SDC-1430

Page 8: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Commit Changes

You should now be back to your Linux desktop.

1. Double-click Terminal.2. Type cd /root/workspace/sample-app and hit Enter.3. Type git add . and hit Enter. Do not forget the space and the period after add.4. Type git commit -m "Updating the code" which commits the changes in the

local repositiory.5. Type git push and hit Enter.

HOL-SDC-1430

Page 8HOL-SDC-1430

Page 9: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Start the Application

Type rails server -p 80 and hit enter. This starts the web server.

HOL-SDC-1430

Page 9HOL-SDC-1430

Page 10: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Test the Application

Launch a web browser from WITHIN the Linux desktop to test the application.Remember, we are simulating what a developer would do using his or her Linuxmachine.

1. Launch Firefox from the toolbar within the Linux desktop.2. Type localhost in the address bar.

You should see the new message you typed in along with the IP of the machine as perthe code in the text editor!

HOL-SDC-1430

Page 10HOL-SDC-1430

Page 11: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Module 2 - Feel the Pain -(45 min)

HOL-SDC-1430

Page 11HOL-SDC-1430

Page 12: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Over the WallIn this Module, the developer will throw his code "over the wall" to the operations team.It's up to the Ops team to operationalize it in a legacy environment with no automation.If you are continuing from the last module, minimize the tightvnc window.

Login to the web-prod server

You are a member of the Operations Team and are told there is an update to anapplication (which you know very little about) that needs to be deployed into productiontoday.

1. Open a PuTTY from the taskbark shortcut2. Select web-prod which is the Production Web Server3. Click Open

HOL-SDC-1430

Page 12HOL-SDC-1430

Page 13: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Pull down the code

This environment does not use much automation today, but at least the developers usea source code repository called Git. Now you need to pull the code and deploy it. Thisnormally only takes a few moments to do.

1. Type cd /opt/webroot/sample-app2. Type git pull which will pull the updates to the code

Start the application

Now you just need to start the application.

HOL-SDC-1430

Page 13HOL-SDC-1430

Page 14: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Problem #1

Now you are ready to start the application and go about your day.

1. Type rails server -p 80 -b 192.168.110.922. Uh oh.

It takes you a moment to dig through the long error message, but you finally see it. Thecode is now requiring a newer version of Ruby than what we had previously! Thosedang developers didn't tell you!!!!

Update Ruby

Normally this would be more involved process, especially in a production environment.For the purposes of simplifying the steps for this lab the new version is staged for you

and just needs a command to use it.

Type rvm use 2.1.5 to switch the version of ruby that will be utilized by thisapplication.

Problem #2

You are ready to start the application and NOW move on with your day.

HOL-SDC-1430

Page 14HOL-SDC-1430

Page 15: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

1. Type rails server -p 80 -b 192.168.110.922. Notice the output looks good now3. Open Firefox from the task bar4. Click on the 'Production Web' shortcut5. Note the connection times out!!!

Shooting that Trouble

That should have worked! Nothing changed (that you know of)! What is going onhere.....?!

Try a Different Port

Let's try a quick test on a different port.

1. Type control-C to kill the running ruby server.2. Run the same command on port 81 this time: rails server -p 81 -b

192.168.110.923. Switch back to Firefox, and load port 81 by adding :81 to the URL

HOL-SDC-1430

Page 15HOL-SDC-1430

Page 16: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

4. Hey that worked!!!

Check Firewall

This place is the wild west with no change management or standardization! Let's seewhat changed. Maybe someone turned on the host firewall?

1. Control-C to stop the service and type service iptables status2. Ah ha! Someone accidentally blocked port 80 on this node. How did we not

know?!

HOL-SDC-1430

Page 16HOL-SDC-1430

Page 17: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Fix the Issue

We'll deal with the intern that caused this mistake later, but for now lets just stop thefirewall and bring up the service.

1. Stop the firewall with /etc/init.d/iptables stop2. Start the service with rails server -p 80 -b 192.168.110.92

App is (finally) deployed

Now switch back to Firefox, click the link we originally tried and see your application inall it's (basic) glory, as it should have been in the first place.

HOL-SDC-1430

Page 17HOL-SDC-1430

Page 18: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Tear down

1. CTRL C the Ruby server. (not pictured)2. Close the Terminal window.

HOL-SDC-1430

Page 18HOL-SDC-1430

Page 19: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Module 3 - Hello Docker! -(30 min)

HOL-SDC-1430

Page 19HOL-SDC-1430

Page 20: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Docker BasicsIn this Module, we will look at the basics of Docker, see it in action, and use Docker inconjunction with VMware to deploy an application. We will also look at some of theDocker management tools available. The intention here is NOT to provide full Dockertraining, but instead provide enough of the basics for the labs to make sense.

Briefly (and straight from the website), Docker is an open platform for developers andsysadmins to build, ship, and run distributed applications. Consisting of Docker Engine,a portable, lightweight runtime and packaging tool, and Docker Hub, a cloud service forsharing applications and automating workflows, Docker enables apps to be quicklyassembled from components and eliminates the friction between development, QA, andproduction environments.

HOL-SDC-1430

Page 20HOL-SDC-1430

Page 21: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Overview

Docker is comprised of a few moving parts. It's important to understand the concepts ofContainers, Images and Registries. Effectively, Docker allows one to abstract anapplication or group of applications into an image (or images) complete with OS. Thisimage can then be run as a container on a Docker host. Multiple containers can be runon Docker hosts. Images (read-only Containers, if you will) can be easily shared viaregistries like Docker Hub. In our lab, the registry will be made local to avoid calling outto the internet.

There is much more to Docker, but understanding these concepts should get youthrough the lab!

Log Into Desktop-01a

If you haven't already done so, launch VNC from the shortcut on the desktop.

1. Double click tightvnc.2. Ensure desktop-01a is the Remote Host.3. Click Connect.4. Type VMware1! in the Password field.5. Click Login.

HOL-SDC-1430

Page 21HOL-SDC-1430

Page 22: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

HOL-SDC-1430

Page 22HOL-SDC-1430

Page 23: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Check Configuration

This step is optional as it has no impact on your lab environment.

1. Double click Terminal.2. From the Desktop-01a command line, type docker info and hit enter.

This will let you know if the Docker installation is healthy. The output in your labenvironment may look slightly different depending on what is running.

Working with Images

NOTE: This step has already been done for you in this lab environment to savetime waiting for the image to download.

Next, we will pull an image from the registry.

1. Type docker pull util-01a:5000/centos6 and hit Enter.

This command finds the image "centos6" in the local registry found at "util-01a:5000". Ifwe were using the public Docker Hub your syntax would be simply 'docker pull centos'to download the official centos image, or a specific one from a vendor 'docker pull

HOL-SDC-1430

Page 23HOL-SDC-1430

Page 24: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

tutum/centos'. (NOTE: These will fail in this lab environment due to lack of publicinternet connectivity)

Working with Containers

In the following steps, we will work with containers in both interactive and daemonmode. One can interact with these containers flexibly as we'll show below.

HOL-SDC-1430

Page 24HOL-SDC-1430

Page 25: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Run the Container as a Daemon

From the desktop-01a command shell:

1. Type docker ps and hit Enter. Depending on what you have done thus far in thelab, you may see any number of running containers, or none at all. In thisscreenshot, there are no running containers.

2. Type docker run -d -t util-01a:5000/centos6 /bin/bash. This will run acentos6 image as a container in daemon mode (versus interactive).

3. Type docker ps and hit Enter. You will see the running containers in yourenvironment. To interact with the container, you would need to execute a dockerattach command from here, but instead, let's look at the interactive shell.

Interactive Shell

In this step, you will run the container you just pulled down and interact with it via theshell.

1. Type docker run -i -t util-01a:5000/centos6 /bin/bash and hit Enter. This willrun an interactive shell with the -i switch. A -d switch, alternately, would run thecontainer as a daemon.

2. Notice that the prompt now displays the machine name of the container. This willbe unique to your lab environment. Type ls and hit Enter to see the filesystem.

3. Type ifconfig and hit Enter. Notice that this is a 172 address because thecontainer is NAT'd. In order to expose the container to network, one needs to bind

HOL-SDC-1430

Page 25HOL-SDC-1430

Page 26: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

the ports, which is out of scope for this particular lab. Feel free to play around inthe container to get a sense of it.

4. Type exit to return to the desktop when finished.

HOL-SDC-1430

Page 26HOL-SDC-1430

Page 27: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Testing Code with DockerIn this section, you will re-take the role of the developer and try testing your Hello Worldapplication within a container. Remember that this is what a developer would do to testhis or her application on their own laptop or in an isolated environment before sending itover to the Operations team.

HOL-SDC-1430

Page 27HOL-SDC-1430

Page 28: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Run a Container

NOTE: The image download has been staged for you to save time waiting for itto download.

In this step, we are going to start a container that houses our new code in daemonmode and allow it to run.

1. If you haven't already done so, launch the Terminal window from the desktop ofdesktop-01a.

2. Type docker run -d -t -p 80:80 util-01a:5000/centos6:stg-v5 /bin/bash -c'/startup.sh && /bin/bash' (Note: This command is available to copy/paste fromthe README.txt file on your Controlcenter desktop.) To explain this command abit, you are instructing Docker to run in daemon mode (-d) on port 80 (-p) and runthe image centos6:stg-v5 (stg-v5 is the tag). Then, you are to launch a bash shelland execute a startup.sh script that we've provided to setup the webserver onthe container.

3. Type docker ps to observe the running container. Note that the ID and Nameswill be different as these are randomly generated.

**Note: if the command does not succeed, make sure you're not in a container! Ensureyour prompt says "root@desktop-01a". If it doesn't, type Exit to leave the container'senvironment.

HOL-SDC-1430

Page 28HOL-SDC-1430

Page 29: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

HOL-SDC-1430

Page 29HOL-SDC-1430

Page 30: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Test Code

Remembering that we're a developer testing this on our laptop, we will now see if ourcontainer is working by checking the website. Ensure you are on the Desktop-01a.You may need to scroll a bit to find this toolbar depending on your resolution.

1. Click the Firefox icon near the top on the toolbar.2. Type localhost in the address bar.3. Observe the output. You should see the HelloWorld app functioning and displaying

an IP address in the 172 range. Why is that? Remember, the container is NAT'd!The webserver in the container believes it is on the 172 address.

HOL-SDC-1430

Page 30HOL-SDC-1430

Page 31: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Docker and VMware - Better Together!Okay, so up to this point, we have been dealing with an isolated environment. Thedeveloper has been using containers on his own machine. While this may be okay fortesting, there is still some work to do before we can be confident this works inproduction! How can we make this easier? By deploying running containers on virtualmachines perhaps? Let's try that.

Review of the Architecture

Let's have a quick review of the architectural possibilities. In previous labs and modules,we have been working primarily in the area marked with a 1 (above). The Docker Serverand Client have been on the same machine. In this lab, we will look at expanding intothe full architecture shown above by utilizing desktop-01a as the Docker Client only,thereby running containers on VMs. There are other options, of course, such asdeploying to vCloud Air or other cloud providers.

Nothing needs to be done on this step.

HOL-SDC-1430

Page 31HOL-SDC-1430

Page 32: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Open C# Client

If you have the desktop-01a environment maximized, please minimize it so you cansee the controlcenter desktop.

1. Click the vCenter icon in the toolbar on the bottom of the screen. Ensure theName is vcsa-01a.corp.local.

2. Click Use Windows Session Credentials box.3. Click Login.

HOL-SDC-1430

Page 32HOL-SDC-1430

Page 33: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Organize the Windows

If you do not currently have a session open to desktop-01a, please open one as perthe instructions earlier in the Module (launch the tightvnc shortcut on thecontrolcenter desktop).

Arrange the vCenter and desktop-01a windows as pictured so you can see the machinesin the C# client get generated in real time.

If one isn't already running, launch a Terminal window in the desktop-01aenvironment.

Start a "Dockerized" VM

This step is optional - but important for you to understand what dockermachine does. The first Docker machine has been staged in the lab for you to savetime (called dockervm0). If you run this step it will create a 2nd one - dockervm1.

HOL-SDC-1430

Page 33HOL-SDC-1430

Page 34: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Type (or copy from text file on ControlCenter desktop) the following in the Terminalwindow on the desktop-01a machine:

machine -D create -d vsphere --vsphere-vcenter="vcsa-01a.corp.local" --vsphere-username="[email protected]" --vsphere-password="vmware123" --vsphere-datacenter="Datacenter" --vsphere-compute-ip="192.168.110.51" --vsphere-datastore="ds-site-a-nfs01" --vsphere-network="VM Network" --vsphere-boot2docker-url="http://util-01a:81/files/boot2docker-custom.iso"dockervm1

As this kicks off, watch the window in the C# client. You will see the VM instantiatealmost immediately. If you do not see it generate or there is an error, please check yoursyntax and/or use the text file on the controlcenter desktop to copy and paste thestring. It is very long! Also, please note we are running this with Debug mode enabled tosee everything that is executed.

Remember that "dockervm1" is the name Docker Machine uses to identify the object.vCenter identifies it differently as "docker-host-xxx".

If you ran this command, now remove the new machine with the command:machine rm dockervm1

HOL-SDC-1430

Page 34HOL-SDC-1430

Page 35: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Using the Machine command

Okay! So now we have a machine deployed in our vSphere environment that is runninga VM that's a Docker Host. So how do we interact with it? Great question! Let's look atthe Machine command.

1. From the desktop-01a Terminal prompt, type machine ls and hit Enter. This willdisplay the machine(s) that you have deployed and their details.

2. Type machine start dockervm0 (this is needed because we staged themachine for you, powered off)

3. Next, type machine url dockervm0 to get the URL of the machine directly. Thiswill be a DHCP address, so it will differ from the screenshot.

4. Now we must change an environment variable to make the Docker Hostinformation readily usable. Type export DOCKER_HOST=`machine urldockervm0` DOCKER_AUTH=identity and hit Enter. (Note 1: this iscurrently needed because of a bug in docker machine. In the future thiswill not be needed) (Note 2: notice this is a backwards tick instead of anormal tick mark because the command within the tick mark needs tobe run to set the variable).

5. Type docker run -d -t -p 80:80 util-01a:5000/centos6:stg-v5 /bin/bash -c'/startup.sh && /bin/bash' and hit Enter. This will start up the docker containeron the VM and execute the preparation scripts as we did locally in previousModules.

6. When an SSL authenticity prompt greets you, type yes and hit Enter. This willtake a minute to complete as you are pulling an image from the util server to thenew VM.

7. Once complete, type docker ps. You should see the container up and running onthe new host! Congrats!

Notice that you ran the exact same docker run command that you ran when running acontainer locally on this linux workstation. To switch back to the local instance, clearthe environment variables with export DOCKER_HOST='' DOCKER_AUTH=''

HOL-SDC-1430

Page 35HOL-SDC-1430

Page 36: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

HOL-SDC-1430

Page 36HOL-SDC-1430

Page 37: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Testing

To ensure everything works as intended, please open a web browser to test the newdeployment.

1. Launch Firefox from the toolbar.2. Type the IP Address from the machine IP in the previous step. You can check the

Docker Host running in vCenter if you don't recall via the vCenter Client! Hit Enterwhen complete.

You should see the NAT'd address of the web server similar to previous labs whendeploying the container locally. This should illustrate the Server-Client relationship thatDocker and VMware can enable together. The developers can work on their code usingcontainers deployed on VMware, thus enabling greater flexibility in how that code isshared and propagated through the lifecycle of the application.

HOL-SDC-1430

Page 37HOL-SDC-1430

Page 38: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Module 4 - The MissingPiece - (60 min)

HOL-SDC-1430

Page 38HOL-SDC-1430

Page 39: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

DevOps Automation with VMwareThis lab will introduce some basic DevOps concepts, along with the tools that VMwarebrings to the forefront.

While there is nothing to do here technically, this information is critical to understandingboth DevOps and VMware's place in the ecosystem.

Intro to DevOps

DevOps is both a hot topic and a buzzword of sorts. There is much discussion as to it'strue definition, but the prevailing wisdom is that DevOps is not a tool, nor is it a role.DevOps refers to the intersection of the development and operations teams; thus,DevOps is focused primarily on aligning these teams and removing impediments tobringing applications to fruition quickly.

Continuous Delivery with VMware

VMware enables development teams and operations teams to work closely togetherthrough a complementary technical framework. For instance, source code repositoriessuch as Git or Subversion are commonly utilized in conjunction with a CI (continuousintegration) tool like Jenkins, which builds artifacts from source code. A tool like jFrog'sArtifactory, which comes onboard the latest version of vRA with a Code Stream license,manages the artifacts (war, jar, exe, etc).

These artifacts need to be tested before they can be used confidently. Mostdevelopment shops automate their testing procedures, though there is typically little

HOL-SDC-1430

Page 39HOL-SDC-1430

Page 40: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

standardization of testing procedures between development teams. This isaccomplished with Code Stream.

VMware, of course, provides robust virtualization of the infrastructure. And as we haveseen in this lab, VMware enables a structured use of containers within the corporate ITenvironment for fast and reliable testing. Excitingly, VMware's newest solution, CodeStream, automates the deployment and testing procedures of source code itself! Thisensures that the building and testing of code is standardized within corporate policy,automated, and the release is then controlled by gating mechanisms which typically fallunder the purvey of a release manager.

HOL-SDC-1430

Page 40HOL-SDC-1430

Page 41: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

How it works (one way!)In this lab, we're going to show some work that has already been done to facilitateautomation between Git, Jenkins, and vRealize Automation. There is technically notmuch for you to do as many of the commands are very long, so we input the strings foryou in places. Nevertheless, it is important to understand the interactions betweenthese components.

Source Control: Git

Git is a source code repository that adeptly handles branching of code and mergeswhich allows many developers to work on the same code at the same time, checking inchanges when appropriate. One major benefit is that a Git branch can be stored locallyso the developer does not necessarily require network access to do work, then check inthe changes when network access is available.

HOL-SDC-1430

Page 41HOL-SDC-1430

Page 42: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Browse to Git

Open Firefox from the ControlCenter desktop, if not already open.

1. Click Git on the toolbar2. Type root3. Type VMware1!4. Click Sign In

HOL-SDC-1430

Page 42HOL-SDC-1430

Page 43: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Click the Sample-App

1. Open Firefox from the taskbar2. Click Git on the Firefox toolbar. If you did the previous module where you

checked code into the repository, you will see your commit here.3. Click sample-app project in the list

HOL-SDC-1430

Page 43HOL-SDC-1430

Page 44: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Browse to Settings

Click on Settings

Browse to Web Hooks

1. Click on Web Hooks located in the left hand menu2. Scroll down to where the configured Web Hooks are listed3. Notice this URL

A Web hook in Git is a REST API call that is made whenever a check in is pushed to thisrepository. This is already configured to call out to Jenkins when code is checked in.Nothing needs to be done here.

HOL-SDC-1430

Page 44HOL-SDC-1430

Page 45: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Continuous Integration: Jenkins

Jenkins is a continuous integrations (CI) tool that allows for the automation of builds.

Browse to Jenkins

1. Click Jenkins on the Firefox toolbar2. Click sample-app project in the list

HOL-SDC-1430

Page 45HOL-SDC-1430

Page 46: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Browse to project Configure

Note the project is currently disabled. This was to prevent any unintendeddeployments, but more on that later.

1. Click Enable2. Click Configure

Project Settings Part 1

The display resolution of the lab environment makes this page hard to navigate, so bearwith us.

Scroll down to the Source Code Management section.

See that Git is selected, and a URL is populated. This defines where the code comesfrom when this Jenkins project initiates a build.

HOL-SDC-1430

Page 46HOL-SDC-1430

Page 47: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Project Settings Part 2

Continue scrolling down to the Build section.

This section defines actions to take on the code once it is pulled from the source coderepository. Here we have simple shell commands. This project is just a simple rubyapplication, but if it was a more complicated application in a language that is compliedlike Java, more advanced (and useful) steps can be taken here like flagging when thecompile fails.

HOL-SDC-1430

Page 47HOL-SDC-1430

Page 48: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Project Settings Part 3

Again, bear with us on the small resolution in the lab. (No one for real uses 1024x768right?) This section will be hard to read, maybe just use the screen shot in this step.

Scroll down to the Post-Build Actions. What is configured here is a REST call via curl tovRealize Automation / vRealize Orchestrator. This begins the deployment of a workloadto utilize the newly commited code.

Deployment Engine: vRealize Automation (vRA)

vRealize Automation is a key central hub in VMware's automation solution. It is anextremely extensible solution with a user-facing catalog that allows for deployment toheterogenous platforms. vRA is integrated significantly with vRealize Orchestrator,which we will look at a bit below.

HOL-SDC-1430

Page 48HOL-SDC-1430

Page 49: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Login to vRA

Open a new browser tab and click on vRealize Automation from the toolbar.

Login with username [email protected] and password VMware1!

HOL-SDC-1430

Page 49HOL-SDC-1430

Page 50: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Catalog Items

Click on Catalog tab at the top.

Shown here are three catalog items in the Self Service Catalog. Each of these arevRealize Orchestrator (vRO) workflows. The REST call we saw in Jenkins previously, isconfigured to start the "Deploy Application" workflow, which can be done manually hereby clicking Request. We will come back to this later, don't run it yet.

Advanced Services

1. Click on Advanced Services2. Click on Service Blueprints3. Note the three blueprints match up with what we saw in the catalog

HOL-SDC-1430

Page 50HOL-SDC-1430

Page 51: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Deployment Location: Docker Machine on vSphere

If you've done previous modules, this image should be familiar to you. If not, this is ahigh level architecture of how Docker and VMware can be leverage together to provideisolation for applications, as well as fast provisioning of workloads. In previous Modules,we have done this (deploying Docker containers on VMs) in a semi-manual process; thatis, we initiated the deployments from the command line.

In the next part of the lab, we will see what end-to-end automation can do to trigger thefull build automatically!

HOL-SDC-1430

Page 51HOL-SDC-1430

Page 52: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Module 5 - DevOpsNirvana - (15 min)

HOL-SDC-1430

Page 52HOL-SDC-1430

Page 53: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

The whole picturePutting together all of the pieces from the previous modules we will now start thepipeline deployment from a check-in to Git which will end with the application deployedin a container and an email to the developer containing a link to it. See the previousmodule #4 for more details of this process if you missed it.

Fire it off!

You may have already done this code check-in part in previous module, the details youput into the code is not important. Firing off the process is the key to what we aredoing.

HOL-SDC-1430

Page 53HOL-SDC-1430

Page 54: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Open a C# Client

First open a C# Client so we can monitor the deployment process. Use the defaultcredentials and click Login.

HOL-SDC-1430

Page 54HOL-SDC-1430

Page 55: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Open vRealize Orchestrator

1. Open Firefox if not already open2. Click on VMware vRealize Orchestrator toolbar shortcut3. Click on Start Orchestrator Client (Click Continue when prompted with Security

Warning)

HOL-SDC-1430

Page 55HOL-SDC-1430

Page 56: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Login to vRealize Orchestrator

Login with [email protected] / VMware1! and click Login.

HOL-SDC-1430

Page 56HOL-SDC-1430

Page 57: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Browse to workflow

1. In the vRealize Orchestrator interface select Design from the drop down2. Expand the workflows shown until "Run Docker Container" is shown. Do not run

this yet.

Note: If you did certain previous labs you may see some already run workflows shownhere, that is fine.

HOL-SDC-1430

Page 57HOL-SDC-1430

Page 58: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Browse to Jenkins

1. Open Firefox if it's not already open.2. Click Jenkins on the Firefox toolbar3. Click sample-app project in the list

If you did not do it in a previous step, be sure to click "enable" on the project

HOL-SDC-1430

Page 58HOL-SDC-1430

Page 59: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Launch VNC

From the ControlCenter desktop:

1. Double-click the tightvnc shortcut.2. The information should be pre-populated. Simply click Connect.3. A password prompt will appear. Input VMware1!4. Click Login.

HOL-SDC-1430

Page 59HOL-SDC-1430

Page 60: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Launch Geany

You are now in the Linux desktop of the developer.

1. Double-click the text-editor Geany.

HOL-SDC-1430

Page 60HOL-SDC-1430

Page 61: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Change the code

You will see some code immediately. This is your extremely simple HelloWorldapplication.

1. Replace "HelloWorld" with "HOL1430 In Action!! Click File -> Save. [or anyother nonsense you want to add!]

2. Minimize the Geany editor. You may need to scroll over to see the minimizebutton, depending on the resolution.

HOL-SDC-1430

Page 61HOL-SDC-1430

Page 62: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Open terminal prompt

You should now be back to your Linux desktop.

1. Double-click Terminal.

HOL-SDC-1430

Page 62HOL-SDC-1430

Page 63: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Arrange Windows

This may be hard to do at the 1024x768 resolution we have to work with, but If you wishto see the automation in progress, arrange the windows so you can see the C# Client,vRO client and Jenkins, along with the command prompt from the Linux desktop.

Commit changes

NOTE: If you did not perform Module 4 on docker: First, run the command machinestart dockervm0 to power on the docker machine that was prestaged for you to speedup this deployment. This is where the container will be deployed on.

Back in the Linux desktop window:

1. Switch to the terminal window.2. Type cd /root/workspace/sample-app and hit Enter.3. Type git add . and hit Enter. Do not forget the space and the period after add.

HOL-SDC-1430

Page 63HOL-SDC-1430

Page 64: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

4. Type git commit -m "Updating the code" which commits the changes in thelocal repositiory.

5. Type git push and hit Enter.

HOL-SDC-1430

Page 64HOL-SDC-1430

Page 65: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Watch the magic happen

This is hard to illustrate in a static picture but in general:

1. The Git push starts the automation via the webhook functionality.2. Jenkins acts on the webhook, and produces a build.3. The vRO workflow is initiated (shown as being complete here)4. A Docker host VM is created5. (Not shown) The container is started on the docker host with the application code

deployed within

HOL-SDC-1430

Page 65HOL-SDC-1430

Page 66: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

Open Thunderbird

Open the E-Mail client on the linux desktop (if not already open)

Find the deployment email

Each deployment in this environment will generate an email with the details required forthe recipient to attach to the box. This can be customized as it's part of a vRealizeOrchestrator workflow.

Verify the workload

Plug this URL into a Firefox and behold your amazing application, that should includeyour newly updated code!

HOL-SDC-1430

Page 66HOL-SDC-1430

Page 67: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

**Note: this may take a couple minutes to respond.

HOL-SDC-1430

Page 67HOL-SDC-1430

Page 68: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

SummaryWe have accomplished a lot with automation today! We hope it was clear what wasbeing accomplished at each step. Let's try to summarize it coherently:

1. A developer "wrote" a very simple Hello World application.2. This application existed on the developer's laptop in a Docker container.3. The developer tested the application to ensure it was working.4. When confident, the developer threw the application over to the operations team.5. The operations team had some issues with the application as the developer's

laptop was not the same as the corporate environment.6. We fixed the issues, drawing attention to the need for the team's to work

together!7. Then we shifted gears a bit and looked closer at Docker. We showed how Docker

and VMware could make developing an application more seamless for bothteams.

8. In Module 4, we walked through some key DevOps concepts focusing primarily onhow VMware integrates with this ecosystem.

9. Next we looked at most of the peripheral CI-type tools like Jenkins and Artifactory.10. Then, we showed how the entire end-to-end automation of a full application build

could be done with vRealize Automation in conjunction with vRealizeOrchestrator, Jenkins, Artifactory and Git.

We hope you enjoyed the lab!

HOL-SDC-1430

Page 68HOL-SDC-1430

Page 69: Table of Contents - VMwaredocs.hol.vmware.com/HOL-2014/hol-sdc-1430_pdf_en.pdf · Docker Basics In this Module, we will look at the basics of Docker, see it in action, and use Docker

ConclusionThank you for participating in the VMware Hands-on Labs. Be sure to visithttp://hol.vmware.com/ to continue your lab experience online.

Lab SKU: HOL-SDC-1430

Version: 20150212-135818

HOL-SDC-1430

Page 69HOL-SDC-1430