Book Image

Containerization with LXC

Book Image

Containerization with LXC

Overview of this book

In recent years, containers have gained wide adoption by businesses running a variety of application loads. This became possible largely due to the advent of kernel namespaces and better resource management with control groups (cgroups). Linux containers (LXC) are a direct implementation of those kernel features that provide operating system level virtualization without the overhead of a hypervisor layer. This book starts by introducing the foundational concepts behind the implementation of LXC, then moves into the practical aspects of installing and configuring LXC containers. Moving on, you will explore container networking, security, and backups. You will also learn how to deploy LXC with technologies like Open Stack and Vagrant. By the end of the book, you will have a solid grasp of how LXC is implemented and how to run production applications in a highly available and scalable way.
Table of Contents (17 chapters)
Containerization with LXC
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface

Autostarting LXC containers


By default, LXC containers do not start after a server reboot. To change that, we can use the lxc-autostart tool and the containers configuration file:

  1. To demonstrate this, let's create a new container first:

          root@ubuntu:~# lxc-create --name autostart_container --template 
          ubuntu
    
          root@ubuntu:~# lxc-ls -f
    
          NAME STATE AUTOSTART GROUPS IPV4 IPV6
    
          autostart_container STOPPED 0 - - -
    
          root@ubuntu:~#
    
  2. Next, add the lxc.start.auto stanza to its config file:

          root@ubuntu:~# echo "lxc.start.auto = 1" >> 
          /var/lib/lxc/autostart_container/config
    
          root@ubuntu:~#
    
  3. List all containers that are configured to start automatically:

          root@ubuntu:~# lxc-autostart --list
    
          autostart_container
    
          root@ubuntu:~#
    
  4. Now we can use the lxc-autostart command again to start all containers configured to autostart, in this case just one:

          root@ubuntu:~# lxc-autostart --all
         ...