I wanted to try an OpenSUSE Leap installation, just needed the shell not some GUI. My first choice in this kind of situation is to install a distro in VM. I was hearing a lot about docker and I said to myself, why not try a docker instead of VM.
First thing that came to my mind was – wait, can docker even run another linux distro? You know, docker images share kernel and I want to run another distro thus another kernel, this is job for virtualization.
I quickly discovered that you can run another linux distro in docker. Why? Well that’s easy. Every linux distro share the same kernel under the hood. Kernels ABI is usually pretty compatible across different versions.
I guess that all apps are just fine as long as they or better say their libs use syscalls that are available in the host kernel.
Now that we all know that docker can run linux distro let’s actually do that.
I’m running OpenSUSE Tumbleweed. It is a rolling-release distro so the steps may change a bit in future, but I think they will apply for at least some years to come.
sudo zypper install docker docker-compose
Add yourself to docker group so you can use it without sudo
sudo usermod -a -G docker your_name
Docker uses a dockerd daemon in the system, it should be running to use docker. Start it with systemctl
sudo systemctl start docker
To have docker auto start on boot enable it
sudo systemctl enable docker
You can check the whole config using
sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2019-01-20 17:45:22 CET; 3h 41min ago
Main PID: 1343 (dockerd)
├─1343 /usr/bin/dockerd --add-runtime oci=/usr/sbin/docker-runc
└─1389 docker-containerd --config /var/run/docker/containerd/containerd.toml --log-level info
Search for the image you want
docker search opensuse
Download the image you want
docker pull opensuse/leap
This will download the latest version of that image, you can specify TAG, but let’s write about that in future post.
Check your installed images
REPOSITORY TAG IMAGE ID CREATED SIZE
opensuse/leap latest bb77bd72ae3d 3 days ago 102MB
You can see the TAG here.
And now – run it
docker run -i -t opensuse/leap /bin/bash
You can check the params help later with
docker help run
Now you are in your new leap. You can look around, do stuff … . I was really curious about the ps aux command, you can try it too. It shows the compactness of containers.
Exit the image using CTRL+D or just type exit. You can now check the help for run or just check another command that list docker containers.
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3d3fd74d0748 opensuse/leap "/bin/bash" 2 hours ago Exited (0) About an hour ago kind_khorana
To attach to the container you have to first start it
docker start 3d3fd74d0748
Then attach to it
docker attach 3d3fd74d0748
After you are done with your container you can just delete it
docker rm 3d3fd74d0748
This will delete the container only, not the image. You can check both with commands before. You can run another container of the image anytime you want.
And that is it. So far docker seems very nice.
In another post I will try to run web server in my container so don’t forget to check it how it will turn out.