Installing LXC/LXD

Hands-On Lab

 

Photo of Ell Marquez

Ell Marquez

Community Architect in Community

Length

00:30:00

Difficulty

Beginner

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.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Installing LXC/LXD

Introduction

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.

Solution

  1. Begin by logging in to the lab server using the credentials provided on the hands-on lab page:

    ssh cloud_user@PUBLIC_IP_ADDRESS

Install the LXD Package

  1. Determine 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

    Accept the defaults for each of the prompts, except for configuring IPv6. Choose No when prompted to set up an IPv6 subnet.

Create Your First Container

  1. Create a container using Alpine 3.6 named my-alpine.

    sudo lxc launch images:alpine/3.6 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 

Conclusion

Congratulations — you've completed this hands-on lab!