Instantiating Containers from Base Images with LXC/LXD
Senior Vice President of Content
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.
Although you have previously configured an LXC/LXD host for your development organization to use, they have been having difficulty with this new method of instantiating and connecting to containers. You have been provisioned access to an Ubuntu 16.04 LTS server in which LXC/LXD is already installed and the service is currently running. You have been asked to troubleshoot several items and then to demonstrate that the server host can successfully run and then connect to a running container on it.
It has been reported that the 'cloud_user' cannot currently run any LXC commands on this host, so your first task will be to see if the user has the appropriate rights and group membership. Additionally, the expected bridge device is not present nor is the local container network configuration. Re-run the configuration utility and check or change the following options from their defaults:
When prompted during the configuration utility run, accept the defaults except where indicated in the list below:
- Provide a subnet value of 10.172.10.1 with a CIDR/Mask value of 24 as the network that containers will reside on the host
- The first IP served via DHCP to containers should be 10.172.10.100
- The last IP served via DHCP to containers should be 10.172.10.149
- Provide a maximum of 50 IPs via DHCP for container use from that network
- Choose NOT to set up an IPv6 connectivity or NAT
- Name the bridge network device 'lxdbridge0' instead of accepting the default
Once you have verified/modified the settings as indicated, run an LXC command as the cloud_user in order to generate the user certificate and show what images, if any, are present on the system. Finally, you will want to pull and run (from the default configured repository for LXC containers) a CentOS 7 image, launching that image with the appropriate command and naming the container 'myweb'.
Verify you can then connect to that container and once you are able to explore the running container, you may exit the container and turn the system back over to your team for use.