Dmitriy Savchenko

Don't panic

To LXC and Beyond

It’s been a while since I’ve started using virtualization.

At first it was VirtualBox vms, then I discovered Vagrant and about half a year ago I’ve noticed LXC and weirdly before that about Docker.

One may ask - why do you need such things and I try to answer.

When I found out about VirtualBox I used computer with Windows7 at work and at home. Being PHP developer at that days meant that you mostly work with LAMP stack on server and with some HTML + CSS + Javascript on client. As you can see I had Linux server and development environment was set up on Windows machine.

It was ok most of the time, but this inconsistency had stub me in the back several times. Then when I once again had fixed some weird bug I decided to start using Linux instead of Windows on my development machine. And before installing Linux as second os I wanted to try some Linux distribution without installing it and screwing all up, so I used VirtualBox for this.

Long term short I was using Ubuntu as my main os for development. Project after project tim goes by and I started to notice some weird thing - after switching to new project some soft kept running in background and number of processes in htop kept growing. Yeah, you may say - stop that process, remove it from upstart, remove it from system or something else, but sometimes these projects may return to life and you would be fixing bugs on them and you would need them kept in ready to go state pretty mach all the time.

This is when I returned to VirtualBox again. This time I installed Ubuntu Server on it and connected to the box over ssh. I was able to install software I need without adding it to host machine, then I could stop and start the box at any time - it was quite amazing. At that time I event wanted to buy bigger usb flash drive to bring my vm with me from work to home and vise versa.

This approach worked fine for a while, but it had some flaws. You could stop and start vm but if you destroy it you are screwed - you need to remember what you did to vm to make your soft work and you need to reapply these changes. This can be some sort of a shell script with installation commands or something more complicated. This same script also can be useful to your team members - they will setup theirs development environments just like you did. Also besides software installations VirtualBox has many setting and options you need to setup every time by hand or using not os friendly api. Having these problems I’ve started looking fo solution and after a while I’ve found one. It was Vagrant.

Vagrant allows you to specify VirtualBox vm settings in Vagrantfile and also you can specify some provision for your box. It can be simple shell script or maybe puppet manifetsts and modules or other provision tool. This way you need to setup Vagrant and VirtualBox on you host machine and then all other soft will be installed inside vm using scripts stored alongside your project files and therefore under version control. This way you won’t forget your dev setup and it won’t be lost. Your team mates will be able to setup same development environment from scratch in minutes.

But as any super power this one comes with some downside. VirtualBox vm is resource consuming. You won’t be able to run Vagrant vm box in production and you can run only several of them on your development environment. Another common problem is files haring between host and guest machines or synced folders. If you have large project syncing process may slow you down and ide will destroy your nerves by even slower reindex (yes, I’m talking about you Php or WebStorm).

And it was exactly the time I’ve heard about LXC - Linux Containers. They are less heavy than VirtualBox vms and in general provide same functionality. You can create container from a template, connect to it and work inside like in vm. One new feature that can be done with containers is running everything inside it. And by everything I mean everything. App soft, git, ide. Yeah, right - ide. I know, I know it sounds weird, but it works. Also running everything app related in one place means disk operations are much faster, for example your ide will reindex project faster, changes to project will be applied fasted and in two ways.

Event If you feel sceptical about it you can try it out and then decide what to do next. Maybe you like it maybe not.

And some words about Docker. Docker can be compared to LXC but they decided to dot it other way. Docker container is intended to run one app. For example if you have LAMP stack - all letters will be in separate containers. It is intended behavior. You can run several apps in one container using something like supervisor. Also Docker provide way to specify your container contents with Dockerfile and you can commit and push containers to repositories.

Thanks to Mak-Di and Vi for pointing out to LXC and initial help.

Useful links:

  1. VirtualBox
  2. Vagrant
  3. Linux Containers
  4. Linux Containers introduction articles
  5. Docker
  6. Running desktop apps in docker container

Zend PHP Certification

If you saw this film - The Graduate, you may remember something weird in that scene.

At last. Wow it was cool. Yay yeah. Wait, now what?

Happy pair enter the bus, they are laughing and shining with joy and then you notice something, as if they start to grasp what happened. I can’t say that I felt exactly the same, but it was close. Maybe both cases can be connected with the accomplishment of the goal, maybe something else, I’ll try to look closer and investigate this question, but not in this post.

So, “Zend PHP Certification” - basic facts:

  • 70 questions: various difficulty
  • 90 minutes: you manage time, can skip questions, mark questions for future review
  • three question types: one answer, multiple answers (number of right answers is specified) and one where you need to type answer (nothing long)

Sources that helped me to prepare for certification:

Tip: Save Document Opened in Vim Without Permissions

This one can save some time for you. How much? It depends on how often you use vim and what you do with it.

Imagine you opened a document im vim and started making changes. Time goes by and you decide to save the document. And guess what - you do not have permissions to do this. You opened some config in /etc/something but you did this as regular user.

At this point you have several ways to overcome this problem, but I only use this one lately.

All you need is instead of typing


to save document, type

:w sudo tee  %

Well, I won’t pretend, at the moment I do not know what this command do exactly, but it helps. This way you can save document (if you know user password or user do not need one and if user can run sudo command)

Symbol ‘Grub_term_highlight_color’ Not Found

Those lines from title wasn’t exactly expected to appear after ubuntu 14.04 update.

It all started kinda from the wrong foot when I decided to finally update my home dual boot setup - ubuntu 13.04/win7.

During the update from 13.04 to 13.10 (it isn’t possible to update from 13.04 to 14.04 - you need to go through all steps) Dropbox failed to update and I noticed this only when I got home from work in the evening. Day wasted.

But I decided that it wasn’t a big deal and I simply cancelled distro upgrade. After reboot I noticed that I already have 13.10. That’s cool I thought andmoved to upgrade to 14.04 after removing Dropbox. All went fine and in the end I clicked Reboot now in the modal window.

And that is when I faced black screen with error from title. To make colors darker - I even couldn’t get to bios when I pressed reboot like 10 times. Strange behaviour. But then I switched computer off and on and was able to get to bios. Hooray.

Hopefully I have notebook and I was able to google solution for this inconvenience. As it always happens first solution is to wipe all drives clean and reinstall everything.

No way I said and kept searching. After some time I found this link which helped me to solve my problem.

Basically all you need is:

  • to create boot cd (wait what?) or flash stick
  • boot from it
  • select “Try ubuntu” option (I assume you created ubuntu boot cd/usb)
  • install boot-repair
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo sh -c "sed -i 's/trusty/saucy/g' /etc/apt/sources.list.d/yannubuntu-boot-repair-trusty.list"
sudo apt-get update
sudo apt-get install -y boot-repair && (boot-repair &)

As you can see this helpful tool isn’t available for 14.04 and you need to switch it’s sources to previous ubuntu version.

  • run
sudo boot-repair

When tool starts it is quite easy to understand what to do (I selected recommended repair) After some time it said that all done and I was able to load both new ubuntu and good old win7.

Tip: Ssh-copy-id Alternative

This one snippet also start to appear in my search results more often.

cat ~/.ssh/ | ssh -o PubkeyAuthentication=no [email protected] "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"

The key part of this one liner is:

-o PubkeyAuthentication=no

You can’t specify it for ssh-copy-id and without it you get this error

$ Received disconnect from host: 2: Too many authentication failures for user

Also other solutions can be found here

Tip: Delete Git Remote Tag

For a quite long period of time I’ve been using this method to delete remote tag in git repository:

  • Find myself in a situation when you totally need to remove that pushed tag
  • Feel frustrated, because even after doing this more than 10 times I still fail to remember the command
  • Google the command
  • Click on that purple link - first in search results for “git delete remote tag”
  • Look at the command and feel embarrassed again
  • Copy paste the command to the terminal window.

Today must admit that I have the problem and the first step to overcome it - add link to solution to this blog:

git tag -d 12345
git push origin :refs/tags/12345


VirtualBox Guest Additions Reinstall

Software development obviously needs some environment. After some time spent working as developer i’ve got strong filling, that this envirement should be separated from my desktop. At least vitrually.

Simple Static Blog Using Octopress

Comes to end year of owning my first hosting. I win it in New Year contest from Logol on Nice hosting, but paying even small amount of money for the thing you use one or two times a month (games twitter and work take almost all my time) is inpractical.