Installing LXC/LXD

30 minutes
  • 5 Learning Objectives

About this Hands-on Lab

This lab will allow you to practice installing LXC/LXD in a cloud server environment. You will pull down the latest Alpine image and create a container from it to test your configuration.

**Note: Use Alpine 3.14 for the lab.**

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install the LXD Package
  1. Verify which Linux distribution your server is running.

    cat /etc/issue
  2. Install lxd and lxd-client.

    sudo apt-get install lxd lxd-client 
Initialize LXD
  1. Initialize LXD.

    sudo lxd init
Create Your First Container
  1. Create a container using Alpine 3.8 named my-alpine.

    sudo lxc launch images:alpine/3.14 my-alpine
List the Containers
  1. List your containers.

    sudo lxc list
Connect to a Container
  1. Execute an ash shell in your my-alpine container.

    sudo lxc exec my-alpine -- /bin/ash
  2. Create a file named hello.txt.

    echo hello world > hello.txt

Additional Resources

Your development team has asked for a cloud server with LXC/LXD configured. To meet this requirement, initialize LXD in your environment and create a new container called "My Container" using the Alpine images.

Reminder: cat /etc/issue will tell you the host operating system.

Update: Use Alpine version 3.14 in the lab.

What are Hands-on Labs

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?