Senthil Kumaran S.

Practical LXC and LXD

Linux Containers for Virtualization and Orchestration

Senthil Kumaran S.

Chennai, Tamil Nadu, India

Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/978-1-4842-3023-7 . For more detailed information, please visit http://www.apress.com/source-code .

ISBN 978-1-4842-3023-7

e-ISBN 978-1-4842-3024-4

https://doi.org/10.1007/978-1-4842-3024-4

Library of Congress Control Number: 2017953000

© Senthil Kumaran S. 2017

This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.

Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.

While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.

Printed on acid-free paper

Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.

To my Father, who taught me “B.B. Roy of Great Britain Has a Very Good Wife.”

Acknowledgments

I have been associated with the Linaro Automated Validation Architecture (LAVA) project for the past 5 years, which is almost from the beginning days of the project. Introduction of Linux Containers (LXC) in the LAVA project has solved many hard to address or complex use cases. This experience I gained with LXC in LAVA is the primary cause for writing this book.

I would like to thank Neil Williams, who leads the LAVA project at Linaro Ltd., for giving me the go-ahead when I floated the idea of writing this book. Steve McIntyre instantaneously accepted the invitation to be the technical reviewer of this book, and he has offered many non-trivial technical suggestions with extraordinary care and commitment to bring this book into the shape it is today. I would like to thank Stephane Graber for his excellent documentation on this topic, from which I started learning about LXC and LXD.

I thank Nikhil Karkal, Apress Acquisitions Editor, who gave me an opportunity and complete freedom right from choosing the idea/topic of this book. Matthew Moodie and Prachi Mehta from Apress helped me to plan and organize the chapters, and were instrumental in realizing this book as planned.

I would like to thank my family and friends, who were the primary source of encouragement to pursue things in my life. Special thanks to my wife, who comes from a medical background but still listened to my endless rants (typically late night) about Linux Containers and my narration of each word before it entered this book.

Contents

  1. Chapter 1:​ Introduction to Linux Containers
    1. Container Definition
    2. Container History
    3. Features to Enable Containers
      1. Control Groups (Cgroups)
      2. Namespaces
      3. Filesystem or rootfs
    4. Summary
  2. Chapter 2:​ Installation
    1. LXC Installation
      1. Installing LXC on Ubuntu
      2. LXC Default Configuration
      3. Networking Setup for LXC
    2. LXD Installation
      1. LXC Requirements for LXD
      2. Installing LXD on Ubuntu
    3. Summary
  3. Chapter 3:​ Getting Started with LXC and LXD
    1. Using LXC
      1. Templates
      2. Basic Usage
    2. Using LXD
      1. Using a Remote LXD As an Image Server
      2. Using the Built-in Remotes
      3. Manually Importing an Image
    3. Running Your First Container with LXD
    4. Summary
  4. Chapter 4:​ LXC and LXD Resources
    1. Default LXC Templates
      1. Download Template
      2. Distribution-Specific Templates
    2. LXD Images
      1. LXD Image Formats
      2. Using LXD Images
    3. Summary
  5. Chapter 5:​ Common Virtualization and Orchestration Tools
    1. libvirt
      1. Starting the Container
      2. Connecting to the Container Console
      3. Monitoring Container Utilization
      4. Rebooting the Container
      5. Stopping and Destroying the Container
      6. Undefining or Deleting a Container from libvirt
    2. Virtual Machine Manager GUI
    3. LXC with SaltStack
      1. Salt Master Setup
      2. Remote Salt Minion Setup
      3. Salt LXC Management
    4. LXC with Vagrant
    5. LXD-WebGUI
      1. LXD Configuration
      2. Using LXD-WebGUI
    6. Summary
  6. Chapter 6:​ Use Cases
    1. Using the Pelican Static Site Generator
    2. Running Android CTS Within LXC
    3. Running Unit Tests in LXC
    4. Running an Application Inside LXC
    5. Rolling Out Memcached Instances with LXC
    6. Doing a Live Migration with LXD
    7. Running Other Architectures
      1. armhf Container
      2. ppc64el Container
    8. Booting a VM Image in LXC
    9. Using JuJu with LXD
    10. Summary
  7. Chapter 7:​ Containers and Security
    1. Cgroups
    2. Capabilities
    3. AppArmor
    4. SELinux
    5. Seccomp
    6. User Namespaces
      1. Privileged Containers
      2. Unprivileged Containers
    7. Containers and Internet of Things (IoT)
    8. Case Study:​ Ubuntu Snappy Core
    9. Summary
  8. Index

About the Author and About the Technical Reviewer

About the Author

A441185_1_En_BookFrontmatter_Figb_HTML.jpg

Senthil Kumaran S. popularly called “stylesen” on the Internet, is from Chennai, India, and is currently working as a LAVA Software Engineer for Linaro Ltd., in Cambridge, UK. He is a free software enthusiast and contributes to many free open source software projects. He is a Full Committer of the Apache Subversion version control system project and a Project Management Committee (PMC) member at Apache Software Foundation. As a Debian Maintainer, Senthil maintains packages such as django-compat and many Linaro Automated Validation Architecture (LAVA)-related packages for the Debian operating system. He has previously authored the book Open Source in the Tamil language. Senthil has contributed many articles to Linux For You magazine and is a regular speaker at various technical events. He holds a bachelor’s degree in Computer Science and Engineering from Thiagarajar College of Engineering, Madurai, India, and a master’s degree in Software Systems from Birla Institute of Technology, Pilani, India.

About the Technical Reviewer

A441185_1_En_BookFrontmatter_Figc_HTML.jpg

Steve McIntyre is a long-time contributor to a range of different Open Source projects but is best known as a developer and Project Leader Emeritus in the Debian project. He lives in Cambridge, England with his wife and their dog.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.16.184