Skip to content

Latest commit

 

History

History
74 lines (59 loc) · 4.65 KB

Module-02.md

File metadata and controls

74 lines (59 loc) · 4.65 KB

Module 2: Docker

Introduction

Docker containers are an integral part of the development and management of our DevOps workflow. After this module, you should be comfortable with basic tasks required to interact and manage containers along with an understanding of their purpose and basic workings.

For this module, create a new Git repo for your Docker work in Module 2.

It is recommended that you read through each of the official documentation resources listed below and follow some of the links within each resource to help clarify specific tools and their purposes.

Resources and articles:


Completing the Module

  1. Install Docker Community Edition for Mac on your local machine.
  2. Create a Docker Hub account if you do not already have one.
  • If you do, please pass that along to a team member so we can add you to our organization.
  1. Login to your Docker Hub account using docker login in your terminal window.

  2. Pull down the alpine:latest image from Docker Hub.

  3. Create a new file called docker-module.txt, and paste the output of docker images into the file.

  4. Commit your changes and push up.

  5. Run sh interactively inside of the alpine:latest container using docker run. You should see a prompt showing / #.

  6. Using apk (more info here), install bash while inside of the container. You'll need add bash using the --no-cache flag.

  7. Start a bash prompt inside of the container, and paste the current prompt into docker-module.txt.

  8. Exit the container.

  9. Commit your changes and push up.

  10. Attempt to run bash inside of the container, and paste the output into docker-module.txt.

    Since containers are immutable, they start in their original state everytime. Since the original state of the container doesn't have bash installed, running the container again restarts the container without bash. This is one of the differences between the way containers and virtual machines handle state.

  11. Commit your changes and push up.

  12. Create a new Dockerfile that extends the alpine:latest and installs bash.

  13. Build a new image with the tag gentux/alpine-bash:{github-username} using your new Dockerfile. e.g. gentux/alpine-bash:jlaswell

  14. Attempt to run bash inside of the new gentux/alpine-bash:{github-username} container, and paste the output into docker-module.txt.

  15. Exit the container.

  16. Commit your changes and push up.

  17. Create a new executable file called welcome.sh containing the following:

#!/bin/bash
echo 'Hello, World!'
  1. Update the Dockerfile so that welcome.sh is added to /home/welcome.sh when the container is built.

  2. Rebuild the container following the the changes.

  3. Run the welcome.sh script within the container using docker run, and paste the output into docker-module.txt.

  4. Commit your changes and push up.

  5. Update the Dockerfile so that it outputs "Hello, World!" when only running docker run gentux/alpine-bash:{github-username}.

  6. Rebuild the container and run it via docker run gentux/alpine-bash:{github-username}.

  7. Paste the output into docker-module.txt.

  8. Commit your changes and push up.

  9. Pull down the dockercloud/hello-world image. You can see the Dockerfile for this image here.

  10. Run the dockercloud/hello-world image without any arguments or flags.

    The container continues to run and never exits. If you look at the Dockerfile, you can see that php-fpm and nginx are running within the container. Since nginx is run with -g "daemon off;", the process never exits and neither does the container!

  11. Rerun docker images and paste the output into docker-module.txt.

  12. Commit your changes and push up.


Wrapping Up

When you are done, verify you have pushed your changes to GitHub. Please create a tag called v1.0 with a message of "ready for review" in your docker repo. Be sure your tags are pushed to the remote repository and are visible in GitHub.

Create an issue titled Review Module 2 - Docker and assign it to @generationtux-helmsmen.