Linux Fu: Docking is easy

Most computer operating systems suffer from some version of “DLL Hell” – a specific Windows term, but the concept applies across the board. Consider doing embedded development that usually takes a few specialized tools. You write down your embedded system code, turn it off, and forget about it for a few years. Then, the end-user wants a change. Too bad the compiler you used needs some libraries that have changed so it doesn’t work anymore. Oops, and the device programmer needs an older version of the USB library. Python build tool uses Python 2 but your system is advanced. If you no longer have the tools you need on your computer, you may have trouble finding and installing your installed media. Worse if you don’t have the right kind of computer for it anymore.

One way to deal with this is to encapsulate all your development projects in one virtual machine. You can then save the virtual machine and it includes an operating system, all the correct libraries and basically a snapshot of how the project was that you can rebuild at any time and almost any computer.

Theoretically, this is great, but it also takes a lot of work and a lot of storage. You need to have an operating system and all the tools installed. Of course, you can get an appliance image, but if you work on many projects, you will have a bunch of copies of the same thing that are a bit messy. You need to keep those copies up-to-date if you want to update things that – granted – are the kind that you might want to avoid, but sometimes you must.

Docker weighs a bit lighter than a virtual machine. You still run the general kernel of your system, but basically you can run a virtual environment instantly on top of that kernel. What’s more, Docker only preserves the difference between things. So if you have ten copies of an operating system, you will only save it once, with a small difference for each instance.

The downside is that it’s a little harder to configure. You need to map the storage and set up the networking among other things. I recently went to a project called Dock which tries to simplify common cases so that you can quickly spin a docker example to do something without any actual configuration. I’ve made a few minor changes and tweaked the project, but, for now, the original has been synced to my fork so you can stick to the original link.

Documentation

Documentation is a bit rare on GitHub pages, but there is a good page of author instructions and videos. On the other hand, it is very easy to get started. Create a directory and go to it (or go to an existing directory). Run “Dock” and you will find a span-up docker container named Directory. The directory itself will be mounted inside the container and will have an ssh connection to your container.

By default, that container will have some nice tools, but I wanted different tools. No problem; You can install whatever you want. You can set up an image of your choice and name it by default in the configuration files. You can also specify the name of a specific image file in the command line. This means that it is possible to setup more than one for a new machine. You can say that you want to configure one image in this directory for Linux development and another for ARM development, for example. Finally, you can also name the container if you do not want to associate it with the current directory.

Pictures

This requires some special docker images that the system knows how to install automatically. There are setups for Ubuntu, Python, Perl, Ruby, Rust and some network and database development environments. Of course, you can customize any one of these and commit them to a new image that you can use unless you confuse things that depend on the tool (e.g., an SSH server, for example).

If you want to change the default image, you can do so at ~ / .dockrc. That file also contains a prefix that removes the name from the system container. Thus, a directory named Hackaday will not end up with a container named Hackaday.alw.home, but only Hackaday. For example, since all my work is in / home / alw / projects, I should use it as a prefix so that I do not have the word project in the name of each container, but – as you can see in the accompanying screenshot – I do not have the container Hackaday.projects As the wind up.

Alternatives and nicknames

You can see the options available on the help page. You can select a user, mount additional storage volumes, set a few container options, and more. I haven’t tried it, but there seems to be one $DEFAULT_MOUNT_OPTIONS Variable for adding other directories to all containers.

My thorns add some extra options that are absolutely not necessary. For one, -h will give you a shorter help screen, while -U will give you a longer help screen. Additionally, unknown options trigger a help message. I added an -I option to write an appropriate source line to add to your shell profile to get optional aliases.

These optional aliases are useful to you, but Doc doesn’t use them so you don’t have to install them. These do things like list docker images or make a promise without remembering the full docker syntax. Of course, you can still use the regular docker command if you wish.

Try it!

To get started, you need to install Docker. Generally, by default, only root dockers can be used. Some setups have a specific group that you can join if you want to use it from your own user ID. Easy to set up if you want. For example:

sudo usermod -aG docker $(whoami)
newgrp docker
sudo systemctl unmask docker.service
sudo systemctl unmask docker.socket
sudo systemctl start docker.service

From there, follow the setup on the project page, and be sure to edit your ~ / .dockrc file. You have to make sure DOCK_PATH, IGNORED_PREFIX_PATHAnd DEFAULT_IMAGE_NAME Variables are set correctly among other things.

Once set up, create a test directory, type dock And enjoy your new kind of virtual machine. Use if you have set up a nickname dc To show you the pots you have. You can use dcs Or dcr To shut down or remove a “virtual machine”. If you want to save the current container as an image, try dcom Holder promises

Sometimes you want to enter fake machine as root. You can use dock-r In short dock -u root Assuming you have installed a nickname.

It’s hard to imagine how much easier it could be. Since the whole thing is written as a bash script, it’s easy to add options (like I did). Looks like it will be quite easy to adapt to existing docker images set up to be compatible with dock. Don’t forget, you can commit a container to use it as a template in future containers.

If you want more background in Docker, Ben James has good writing. You can even use Docker to make retrocomputing easier.

Leave a Reply

Your email address will not be published.