I am looking for an Ubuntu virtual machine to use in order to follow along in a basic course on the Linux command line.
I had an Ubuntu installed in VirtualBox that worked well.
But ever since I installed Docker, it doesn't work any more, keeps crashing, etc.
So I thought I would use Ubuntu in a Docker container.
I pulled the standard docker image:
https://hub.docker.com/_/ubuntu
and am able to enter it via docker run --name ubuntu002 -it ubuntu bash
but it is missing many commands, e.g. systemctl
, less
, sudo
etc.
So is it possible to use a Ubuntu Docker container as a regular Ubuntu system or is it some kind of incomplete Ubuntu system?
Docker containers, are generally built with different goals in mind than machines intended to run on bare metal, or as virtual machines.
Most programs can be installed into a container, for example, I was able to install 'less' and 'systemctl' using apt-get, after running
apt-get update
first.The reason the default Ubuntu container will have less programs installed, is due to the general goal that containers should be small, start quickly, and use up as little disk/cpu/ram as possible.
That said, it is very likely the Ubuntu Docker Image will have some customisation that deviate from a typical Ubuntu install, and will behave a little differently. For example, if you start a Ubuntu container using the command above, there will be no running background tasks, no services daemon.
The idea is that if you need to run an 'Ubuntu app' inside a container, for which it is running on top of some other OS, you don't need Ubuntu to manage the system's clock, or USB ports, as that is handled by the host OS, you only want the 'Ubuntu app' running, and nothing else. With this in mind, you wouldn't generally want to have 'systemctl' installed.
If you wanted to run a webserver inside of of an Ubuntu container, instead of starting the container with the 'bash' executable, you would start it with say the 'nginx' executable, and not require anything else.
The Docker image for Ubuntu (or any distro) is a slim version that includes only a subset of the packages found in the full install.
However, you can install any packages to provide functionality that you want but remember that Docker containers do not provide access to the entire host's architecture by design including some functions provided by the host like logging and networking. This may or may not not affect you in a course on basic linux CLI.
will show you installed packages. To find what package contains the command you are missing apt-file will help.
https://askubuntu.com/questions/481/how-do-i-find-the-package-that-provides-a-file
FWIW, KVM/qemu comes already installed in Ubuntu and I find it more stable/performant and easier to use than VirtualBox if you decide to go that route.