- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud

Managing Files on LXD Containers
LXD offers a command-line interface for efficiently managing files on our Linux containers. We can both push and pull files to and from our containers, or leverage the `edit` command to edit files without ever having to log in to the container directly. In this lab, we'll be using all of these commands to configure Apache on an Ubuntu Linux host.

Lab Info
Table of Contents
-
Challenge
Create the containerhub Configuration
-
Copy an existing profile:
lxc file pull web01/etc/apache2/sites-available/000-default.conf containerhub.conf
-
Update the
containerhub.conf
file:vim containerhub.conf
<VirtualHost *:80> ServerName www.containerhub.example ServerAdmin hub@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
-
Push the file to the container:
lxc file push containerhub.conf web01/etc/apache2/sites-available/containerhub.conf
-
Confirm the file was added:
lxc file edit web01/etc/apache2/sites-available/containerhub.conf
-
-
Challenge
Enable the New Configuration
-
Remove the old
000-default.conf
configuration from thesites-enabled
directory:lxc file delete web01/etc/apache2/sites-enabled/000-default.conf
-
Enable the new configuration:
lxc exec web01 -- a2ensite containerhub lxc exec web01 -- systemctl reload apache2
-
-
Challenge
Test the New Configuration
-
Update the
index.html
file to say a simple sentence:lxc file edit web01/var/www/html/index.html
Website test
-
Retrieve the private IP address of the container:
lxc list
-
Curl the website:
curl <web01_private_ip>
-
About the author
Real skill practice before real-world application
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.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.