- Lab
- A Cloud Guru
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.
Path 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>
-
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.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.