Hello all. I am new to containers and I just wanted to ask if it is possible to deploy django application using LXC like the way it is done with docker. Secondly which organisation provide this type of service?. I know with docker we use the Dockerfile, how is it done with LXC?
First of all, there is a bit of difference between plain LXC and LXD (LXD/LXC). As a new user, it is suggested to look for LXD, which simplifies greatly how containers (machine containers) work. The term machine container means the container feels just like a full Linux machine, and you deal with it just like you would deal with a new server. And you can have many of those inside your computer. See more at https://discuss.linuxcontainers.org/t/comparing-lxd-vs-lxc/24
If I were to install a django application, I would
- Set up LXD according to https://stgraber.org/2016/03/11/lxd-2-0-blog-post-series-012/ (or https://blog.simos.info/trying-out-lxd-containers-on-our-ubuntu/ )
- Create a machine container for django,
lxc launch ubuntu:16.04 mydjango
lxc listto see the private IP address of the machine container.
- Connect to the machine container mydjango,
lxc exec mydjango -- sudo --login --user ubuntuand you get a shell as user ubuntu (that can sudo to root without password).
- Install django and your app as you would normally do. Then, on Firefox, connect to the IP address of the machine container (the private IP address that you get when you run
Thank you @simos. So this means I can deploy my website to a VPS like Linode or Digital Ocean after installing LXD ?
Okay great, I found this https://blog.simos.info/trying-out-lxd-containers-on-ubuntu-on-digitalocean/ to be very helpful. I have been tinkering with LXC and am very comfortable with it and I can do the same with it right?
There is an updated tutorial for LXD on DigitalOcean at https://www.digitalocean.com/community/tutorials/how-to-set-up-and-use-lxd-on-ubuntu-16-04
It should be similar to other VPS, including Linode. For Linode, you would need to use the Ubuntu stock kernel for the best experience. That is, in the list of kernel, select 'GRUB2', which defaults to the Ubuntu stock kernel. The Ubuntu stock kernel has both ZFS and AppArmor included.
If you are familiar with plain LXC, LXD would be far easier for you to use. You can do the django app in a LXD container. For a similarly advanced tutorial, see also https://www.digitalocean.com/community/tutorials/how-to-host-multiple-web-sites-with-nginx-and-haproxy-using-lxd-on-ubuntu-16-04