- A Cloud Guru
Instantiating Containers from Base Images with LXC/LXD
With containers being an important part of any dynamic IT organization, understanding how to work with them is a key component to your success as an engineer. In this activity, you will get a chance with work with images and instantiuate containers using the LXD/LXC container management engine. Once you complete this activity, you will have an understanding of how to pull, start and connect to LXC containers running on your host.
Table of Contents
Reconfigure the LXC/LXD Host
Using the requirements from your Activity Guide, you will need to reconfigure the host to be sure the settings are as intended. You can accomplish that with the following command:
sudo lxd init
Non-privileges User 'cloud_user' Needs to Be Able to Run LXC Commands
Check /etc/groups, look for the 'lxd' group. If the 'cloud_user' user is not a member, then do:
sudo usermod -aG lxd cloud_user
To add them. You WILL Have to log completely off and back in for the membership to pick up in the shell (or start a new bash instance without logging out)
Pull a CentOS 7 Image and Run a Container
You can launch a container instance called 'myweb' based on the CentOS 7 image provided by the default repositories with the command:
lxc launch images:centos/7 myweb
You can verify with
Which will show the running container. Connecting to it can be done via:
lxc exec myweb -- /bin/bash
You will be logged into the container. You can log out with 'exit' and then stop the container with
lxc stop myweb
Verify the image is still there with
lxc image list
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.