Docker is a virtualization application that allows you to work with containers. Containers are like virtual machines and allow applications to run in their own isolated environment that runs on top of Docker. This allows you to run open source applications in a sandbox environment. You can think of docker as a hypervisor and the applications like a VM instance. In this tutorial, we will cover installation and do a brief introduction on how to run a docker container. Let's get started!
First, let's open up a terminal session by selecting and search for the terminal in the search bar and click to open.
Now, let's make sure our system repositories are up to date.
sudo apt update
Next, we will need to download a few dependencies needed for docker.
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Adding gpg key
Adding the gpg key will make sure that the software we are downloading is the actual software by authentication.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
Now we need the Installation of the Docker Repository and update our system repository once more.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
Now we can install Docker
sudo apt-get install docker-ce
Verifying Docker install
Use the command below to verify docker installation
Start/enable Docker Service to run at boot
sudo systemctl start docker
sudo systemctl enable docker
Check docker status to verify that it is running
sudo systemctl status docker
Now that we have verified docker is installed and running we can now run our first container (we must do this as sudo).
Running your first docker container
Let's run the following command to run our first container
sudo docker run hello-world
Now that we have run our first container let's try a few other commands as well
Running a Fedora container in Docker on Ubuntu
Containers are virtual environments so you can run applications separately. Here we will briefly go over how to run a container
To run a container use the following command
sudo docker run “container name”
To run and interact with the container run the following command
sudo docker run -it “container name”
Example of running fedora on docker in Ubuntu
sudo docker pull fedora
sudo docker run -it fedora
Above you can see that now I am in a fedora terminal session. To leave a container just type exit in the terminal.
And that it’s it. Now you can run your own virtual environments within ShellsTM. For more in-depth documentation you can click on the link below.