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.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- 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
- 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
- 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>