Navio
Navio is a simple tool for creating and managing linux containers.
A container is a set of processes isolated by Linux namespaces. We use, for example, PID namespace to isolate the PID number space, UTS to isolate the hostname and MOUNT to isolate the filesystem mount points.
All containers have their own rootfs (a isolated "mini operating system") associated, so that a change (for example, an installation of any library or a creation of a file) in a container does not affect others ones.
It is also possible use Cgroups
to limit the amount of resources that each container can use.
Why?
For study purposes only. If you want to use real containers use Docker or Containerd.
Available Default Images
Image | version | size |
---|---|---|
alpine | v3.11 | 2.7M |
busybox | v4.0 | 1.5M |
ubuntu | v20.04 | 90M |
These are the default images, but you can easily create your own images with the packages and files you find necessary. For example, with the following Naviofile:
FROM ubuntu
ADD . /mydir
RUN apt update && apt upgrade -y && apt install python -y
cd /path/to/Naviofile
sudo navio build . --t python-image
we created an image with python installed, so the containers that use this image will already have python installed by default, as well the files from the current directory that will be copied to the /mydir
directory in the container.
Demo
Namespaces
what the processes can see
-
UTS - isolate hostname and domainname
-
PID - isolate the PID number space
-
MNT - isolate filesystem mount points
Cgroups
what the processes can use
-
Memory
-
CPU
-
Process numbers
Available Commands
How to use
To create a basic container just type:
sudo navio create ubuntu bash
But you can use some flags, ex:
--name ubuone
to define the name of container
--pids 25
to limit the maximum number of processes that the container can create
--cpus 0-3
to limit the cpu cores that the container can use. For example, in this case (0-3) if you computer have at least 4 cores, this flag will permit that the process of container use only 4 cores, no more
--cpus-share 100
--memory 1G
to limit the maximum memory RAM that the container can use
Limiting the container to use only 4 cpu cores
Building new Images
To build a image you need first create a Naviofile with the base image and the commands.
Limitations
- The network is not being isolated and is only working on the ubuntu image.
- The Navio does not allow containers to run in the background.
- The Navio does not limit the use of I/O
Requirements
- linux. Navio's doesn't support other operational system :(
- golang environment
- make
- wget
- mysql configured with the root password ==
root
- some of commands (ex.:
navio build
,navio create
,navio rmi
andnavio exec
) must be executed with sudo privilegies.
How to install
1°: we assume that your root mysql database user and password is 'root', feel free to change it locally.
If you just want use, is very simples
git clone https://github.com/viniciusbds/navio.git
cd navio
./install.sh
If you want compile the code before install
git clone https://github.com/viniciusbds/navio.git
cd navio
make
./install.sh
To run all unit tests, type
cd /path/to/project/navio
sudo make unit-tests
To uninstall
cd navio
./uninstall.sh
Example Commands
$ navio images
$ sudo navio create ubuntu bash --name mycontainer`
$ navio containers
ID NAME IMAGE COMMAND STATUS
14806622 mycontainer ubuntu bash Stopped
$ sudo navio exec 14806622 bash
$ navio rename 14806622 new_name
$ sudo navio create busybox sh
$ sudo navio create alpine /bin/sh --name levezin
Contributing
You can contribute to the project in any way you want, either by fixing bugs, implementing new features, improving the documentation or proposing new features through issues
See Contributting for more details