I am interested in the idea of Flockport: providing ready built LXC containers for download. So I wanted to try to see how I can actually download a Flockport container and install it on a Jiffybox (the German equivalent to the American Linode…)

See also my old post: LXC Linux containers on JiffyBox running CentOS on Ubuntu

So, I install a Jiffybox with Ubuntu 14.04 64 bit operating system, 2 GB RAM.

Install lxc (currently 1.0.6) from the default Ubuntu repositories:

apt-get install lxc

Now to Flockport: Check out these pages, my next steps are based on the instructions there:

I chose the WordPress container as an example. See http://www.flockport.com/apps/wordpress/

I wanted to download the Debian Wheezy 64 Bit package called wordpress.tar.xz, but that does not work like that, because you need to be logged in.

Here comes the Flockport utility into play. It is currently in Alpha, but it works ok, even on Ubuntu, though it is only advertised for Debian:

To install the Flock utility, follow these steps:

wget http://repo.flockport.com/flockport.gpg.key
apt-key add flockport.gpg.key
echo "deb http://repo.flockport.com/debian wheezy main" > /etc/apt/sources.list.d/flockport.list
apt-get update
apt-get install flockport

Note that I am not installing lxc from the Flockport repository, but only the Flockport utility.

Some useful commands with the Flockport utility:

#shows all Flockport containers available
flockport list 
 
# login with your username and password for http://www.flockport.com/
flockport login
 
# download a container, the names were displayed by the list command above
flockport get wordpress

The Flockport utility will download the container, and extract it to /var/lib/lxc.

# shows the new container
lxc-ls -f
 
# start the container
lxc-start -d -n wordpress 
 
# now show the running container, and the currently used IP address:
lxc-ls -f 
 
#output:
#NAME      STATE   IPV4        IPV6  AUTOSTART
#-----------------------------------------------
#wordpress RUNNING 10.0.3.227  -     NO

To make this container accessible to the outside, you can use iptables:

containerIP=`lxc-ls -f -F name,ipv4 | grep wordpress | awk '{ print $2 }'`
interface=`cat /etc/network/interfaces | grep "auto" | grep -v "auto lo" | awk '{ print $2 }'`
HostIP=`ifconfig ${interface} | grep "inet addr" | awk '{ print $2 }' | awk -F ':' '{ print $2 }'`
iptables -t nat -A PREROUTING -d ${HostIP}/32 -i ${interface} -p tcp -m tcp --dport 80 -j DNAT --to-destination ${containerIP}:80
echo "make sure that mywordpress.org resolves to this HostIP: " ${HostIP}

If mywordpress.org resolves to the IP of your Jiffybox, then you can visit the WordPress installation by browsing to http://mywordpress.org

To change the domain name from mywordpress.org to the actual domain name that you want to use, you have to first go into http://mywordpress.org/wp-login.php, login with username admin and password flockport, change the password, and change in General Settings the WordPress URL and the Site URL to your desired domain name, eg. helloworld.org

You also have to change the Nginx configuration inside the container to replace the domain name with your actual domain name for your website:

# switch inside the container
lxc-attach -n wordpress
 
# unfortunately no vi available, but nano will do as well:
nano /etc/nginx/sites-available/mywordpress.org
 
# add helloworld.org or your domain name to the 4th line:
#    server_name mywordpress.org www.mywordpress.org helloworld.org;
# leave nano with Ctrl-X, and don't forget to save...
 
# reload nginx for the change of configuration to take effect
service nginx reload

Now you can reach the server on your own domain name, that points to your Jiffybox!

Using Flockport with Jiffybox
Markiert in: