Home

About

docker-scripts are Bash scripts that are used to manage Docker containers.

Docker commands have lots of arguments and options and they tend to be very long. It is tedious and error prone to type these commands manually, so recording them in Bash scripts is a necessity. However the scripts of different containers also have a lot of things in common, which would be nice to abstragate and reuse. And this is one of the things that docker-scripts does. It is like a framework that makes building and using such scripts easy.

Is docker-scripts sort of re-implementation of docker-compose in Bash?

You can think of docker-scripts as kind of an alternative to docker-compose, in the sense that what they try to achieve is similar. But it is not a re-implementation of docker-compose.

I started to use Docker quite early (before version 1.0). Before that I was using chroot to isolate applications from each-other. I was using bash scripts to manage applications before using Docker, then I converted them to use Docker. Actually, a source of inspiration for me was TurnKeyLinux. One of the problems with TKL is that it requires a separate server (or VPS) for each application that you install, which I could not afford. So, I was trying to install different applications on the same server, in such a way that they don’t mess with each-other (are isolated from each-other). I found Docker useful for this.

Besides, the goals of docker-scripts and docker-compose are not exactly the same. For example, each container of docker-scripts runs systemd, so that it can easily manage different services inside the same container (for example apache2, mariadb, cron, logwatch, etc.) Maybe you can do the same thing with docker-compose, but the philosophy of docker-compose is that you should run each service in a separate container, and use docker-compose to connect these services to each-other. The philosophy of docker-scripts is that you install all the services related to an application in the same self-sufficient container. In this respect, a docker-scripts container is kind of similar to a light-weight virtual machine. For example, to install Moodle with docker-compose, you need to run at least 3-4 containers. With docker-scripts there is just one self-sufficient container that has all the required services and tools inside.

This difference in philosophy implies also a difference in the way that an application is installed. With docker-scripts the way of installation is more traditional, almost the same way that you would install an application in a VM or a VPS. The novelty is that you use bash scripts to automate the installation steps (strangely, it is not so easy to use bash scripts inside docker containers). I haven’t tried it yet, but maybe you can use Ansible scripts as well inside a docker-scripts container.

With docker-compose installation of applications is quite different from the traditional way, more involved in my opinion, adding an additional layer of complexity.

I also think that docker-scripts, being based on bash scripts, are more flexible and powerful, compared to docker-compose. For example it is possible to use docker-scripts to manage a docker-compose application. For example I use Talkyard (free software, self-hosting) as an alternative to Disqus (proprietary, centralized), for adding comments to my websites. It does not provide any instructions for a traditional installation, it offers only docker-compose instructions. Instead of reinventing the wheel, I have written a docker-scripts wrapper for managing this application the same way that I do with the other applications (https://gitlab.com/docker-scripts/talkyard/-/blob/master/ds.sh).

Trying examples

The commands of docker-scripts are meant to be used in a server (or VPS) and they need to be executed as root. When trying the examples that are provided in the docs, it is safer to use a dedicated VPS or a virtual machine.

It is not recommended to try them directly on your personal machine (laptop).

They are not meant to do any harm, but you never know, maybe there is a bug, or some mistyping, or something else.

There are lots of ways for running a virtual machine, but an easy and convenient way is to create and setup an Incus container:

There are also some (kind of) interactive tutorials, based on the examples in the docs: https://gitlab.com/docker-scripts/tutorials

You may give them a try, if you are a bit lazy; they may save you some typing (or copy/pasting).