You are previewing Mastering Docker.
O'Reilly logo
Mastering Docker

Book Description

Rethink what’s possible with Docker – become an expert in the innovative containerization tool to unlock new opportunities in the way you use and deploy software

About This Book

  • Create highly scalable applications and services using the Linux container virtualization paradigm

  • Extend Docker with external platforms, including Heroku and OpenStack

  • Integrate with some of the most innovative and exciting orchestration tools such as Kubernetes for larger and more controlled deployments

  • Who This Book Is For

    If you recognize Docker’s importance for innovation in everything from system administration to web development, but aren’t sure how to use it to its full potential, this book is for you.

    What You Will Learn

  • Become fluent with the basic components of Docker

  • Learn best practices for storing and managing Docker files

  • Secure your containers and files with Docker’s security features

  • Learn how to use Docker machine to build new servers from scratch

  • Find out how to set up and manage multiple environments with Docker compose

  • Utilize Docker Swarm to orchestrate containers across different servers

  • Integrate Docker with a wide range of cloud and configuration tools to fully realize its potential

  • In Detail

    Docker has been a game-changer when it comes to virtualization – it has now grown to become a key driver of innovation beyond system administration, having an impact on the world of web development and more. But how can you make sure you’re keeping up with the innovations that it’s driving? How can you be sure you’re using it to its full potential? Mastering Docker shows you how – it not only demonstrates how to use Docker more effectively, it also helps you rethink and reimagine what’s possible with Docker.

    Covering best practices to make sure you’re confident with and the basics, such as building, managing and storing containers, before diving deeper into Docker security, you’ll find everything you need to help you extend and integrate Docker in new and innovative ways. You’ll learn how to take greater control over your containers using some of Docker’s most sophisticated and useful tools, such as Docker compose and Docker swarm, before bringing together everything you already know and have learned to put your containers into production and monitor them for safety and performance.

    Beyond this, you’ll also explore even more advanced strategies, as you learn how to extend and integrate Docker with cloud platforms such as Heroku and OpenStack, and how tools such as Kubernetes can improve the way you manage large-scale container orchestration. With further guidance on how you can use configuration management tools such as Puppet, Chef and PowerShell, by the end of the book you’ll have a broad and detailed sense of exactly what’s possible with Docker – and how seamlessly it fits with a range of other platforms and tools.

    Style and approach

    This book takes you through some of the most sophisticated Docker tools in a way that’s accessible and practical. It has been created to help you put new ideas in practice – and to demonstrate precisely what’s possible with Docker.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Mastering Docker
      1. Table of Contents
      2. Mastering Docker
      3. Credits
      4. About the Author
      5. About the Reviewer
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      8. 1. Docker Review
        1. Understanding Docker
          1. Difference between Docker and typical VMs
          2. Dockerfile
          3. Docker networking/linking
        2. Docker installers/installation
          1. Types of installers
          2. Controlling the Docker VM (boot2docker)
          3. Docker Machine – the new boot2docker
          4. Kitematic
        3. The Docker commands
          1. The Docker images
          2. Searching for the Docker images
          3. Manipulating the Docker images
        4. Stopping containers
        5. Summary
      9. 2. Up and Running
        1. Dockerfile
          1. A short review of Dockerfile
            1. Reviewing Dockerfile in depth
            2. LABEL
            3. ADD or COPY
            4. ENTRYPOINT
            5. USER
            6. WORKDIR
            7. ONBUILD
          2. Dockerfile – best practices
        2. Docker build
          1. The docker build command
            1. .dockerignore
          2. Building images using Dockerfile
          3. Building a base image using an existing image
          4. Building your own containers
            1. Using tar
            2. Using scratch
        3. Docker Hub
          1. The Docker Hub location
          2. Public repositories
          3. Private repositories
          4. Docker Hub Enterprise
        4. Environmental variables
          1. Using environmental variables in your Dockerfile
          2. Creating a MySQL username, database, and setting permissions
          3. Adding a file to the system
        5. Docker volumes
          1. Data volumes
          2. Data volume containers
            1. Docker volume backups
        6. Summary
      10. 3. Container Image Storage
        1. Docker Hub
          1. Dashboard
          2. Explore the repositories page
          3. Organizations
          4. The Create menu
          5. Settings
          6. The Stars page
        2. Docker Hub Enterprise
          1. Comparing Docker Hub to Docker Subscription
          2. Docker Subscription for server
          3. Docker Subscription for cloud
        3. Docker Registry
          1. An overview of Docker Registry
          2. Docker Registry versus Docker Hub
        4. Automated builds
          1. Setting up your code
          2. Setting up Docker Hub
          3. Putting all the pieces together
          4. Creating your own registry
        5. Summary
      11. 4. Managing Containers
        1. The Docker commands
          1. docker attach
          2. docker diff
          3. docker exec
          4. docker history
          5. docker inspect
          6. docker logs
          7. docker ps
          8. docker stats
          9. docker top
        2. Using your existing management suite
          1. Puppet
          2. Chef
          3. Ansible
          4. SaltStack
        3. Docker Swarm
          1. What is Docker Swarm?
          2. What can Docker Swarm do?
        4. Summary
      12. 5. Docker Security
        1. Containers versus VMs
          1. The good
          2. The not so bad
          3. What to look out for
        2. The Docker commands
          1. docker run
          2. docker diff
        3. Docker security – best practices
          1. Docker – best practices
          2. CIS guide – host configuration
          3. CIS guide – Docker daemon configuration
          4. CIS guide – Docker daemon configuration files
          5. CIS guide – container images/runtime
          6. CIS guide – Docker security operations
        4. The Docker bench security application
          1. Running the tool
          2. Understanding the output
        5. Summary
      13. 6. Docker Machine
        1. Installation
        2. Using Docker Machine
          1. Local VM
          2. Cloud environment
        3. Docker Machine commands
          1. active
          2. config
          3. env
          4. inspect
          5. ip
          6. kill
          7. ls
          8. restart
          9. rm
          10. scp
          11. ssh
          12. start
          13. stop
          14. upgrade
          15. url
          16. TLS
        4. Summary
      14. 7. Docker Compose
        1. Installing Docker Compose
          1. Installing on Linux
          2. Installing on OS X and Windows
        2. Docker Compose YAML file
        3. The Docker Compose usage
          1. The Docker Compose options
        4. The Docker Compose commands
          1. build
          2. kill
          3. logs
          4. port
          5. ps
          6. pull
          7. restart
          8. rm
          9. run
          10. scale
          11. start
          12. stop
          13. up
          14. version
        5. Docker Compose – examples
          1. image
          2. build
          3. The last example
        6. Summary
      15. 8. Docker Swarm
        1. Docker Swarm install
          1. Installation
        2. Docker Swarm components
          1. Swarm
          2. Swarm manager
          3. Swarm host
        3. Docker Swarm usage
          1. Creating a cluster
          2. Joining nodes
          3. Listing nodes
          4. Managing a cluster
        4. The Docker Swarm commands
          1. Options
          2. list
          3. create
          4. manage
        5. The Docker Swarm topics
          1. Discovery services
          2. Advanced scheduling
          3. The Swarm API
        6. The Swarm cluster example
        7. Summary
      16. 9. Docker in Production
        1. Where to start?
          1. Setting up hosts
          2. Setting up nodes
        2. Host management
          1. Host monitoring
          2. Docker Swarm
          3. Swarm manager failover
        3. Container management
          1. Container image storage
          2. Image usage
          3. The Docker commands and GUIs
          4. Container monitoring
          5. Automatic restarts
          6. Rolling updates
        4. Docker Compose usage
          1. Developer environments
          2. Scaling environments
        5. Extending to external platform(s)
          1. Heroku
        6. Overall security
          1. Security best practices
        7. DockerUI
        8. ImageLayers
        9. Summary
      17. 10. Shipyard
        1. Up and running
        2. Containers
          1. Deploying a container
        3. IMAGES
          1. Pulling an image
        4. NODES
        5. REGISTRIES
        6. ACCOUNTS
        7. EVENTS
        8. Back to CONTAINERS
        9. Summary
      18. 11. Panamax
        1. Installing Panamax
        2. An example
          1. Applications
          2. Sources
          3. Images
          4. Registries
          5. Remote Deployment Targets
          6. Back to Applications
          7. Adding a service
          8. Configuring the application
            1. Service links
            2. Environmental variables
            3. Ports
            4. Volumes
            5. Docker Run Command
        3. Summary
      19. 12. Tutum
        1. Getting started
        2. The tutorial page
        3. The Service dashboard
        4. The Nodes section
        5. Cloud Providers
        6. Back to Nodes
        7. Back to the Services section
          1. Containers
          2. Endpoints
          3. Logs
          4. Monitoring
          5. Triggers
          6. Timeline
          7. Configuration
        8. The Repositories tab
        9. Stacks
        10. Summary
      20. 13. Advanced Docker
        1. Scaling Docker
        2. Using discovery services
          1. Consul
          2. etcd
            1. Debugging or troubleshooting Docker
          3. Docker commands
          4. GUI applications
          5. Resources
        3. Common issues and solutions
          1. Docker images
          2. Docker volumes
          3. Using resources
        4. Various Docker APIs
          1. docker.io accounts API
          2. Remote API
        5. Keeping your containers in check
          1. Kubernetes
          2. Chef
          3. Other solutions
        6. Contributing to Docker
          1. Contributing to the code
          2. Contributing to support
          3. Other contributions
        7. Advanced Docker networking
          1. Installation
          2. Creating your own network
          3. Networking plugins
        8. Summary
      21. Index