Docker & Container Runtimes, Fedora

How to install Docker and run Docker containers on Fedora 25

Docker is an open source project supported by a commercial entity of the same name that makes it super-easy to run an application process inside a relatively isolated environment called a container. Unlike a virtual machine (VM), which has its own kernel, a container is dependent on the host operating system’s kernel.

As a result, it’s much lighter and boots up much faster. It’s the simplest tool that puts enterprise-class application deployment and management capabilities right on your desktop (laptop). By default, Docker containers are run using application images hosted on Docker Hub.

In this article, we’ll go through the process of installing and using it to run containers on any desktop flavor of Fedora 25.

Install Docker on Fedora 25

Every task will be completed from the command line, so fire up a terminal emulator. The latest version of Docker is in the Fedora official repository, so all you need to install Docker is type the following command:

That installs the latest Docker Engine (version 1.12.3), which consists of the Docker daemon and Docker client. Because one needs the other to do anything useful, you first need to start the daemon and configure the system to start it every time the computer is (re)booted. The following pair of commands will accomplish that.

Run Docker Containers on Fedora 25

The Docker daemon is now up and running, so you can run your first container. By default, the Docker is pointed to Docker Hub, which holds hundreds (perhaps thousands) of images waiting to be used to run containers. But let’s start by running the famous Hello World of the (Docker) container universe.

The container will run and exit, because that’s how it was configured to behave. In the output, you’ll see lines like those below.

The above output tells you each step involved, and what else you can run, so let’s try running the suggested container, using an official Ubuntu image. Unlike the first container you just ran, this one will not exit soon after running. Instead, the command will run the container, keep it running, and give you interactive tty access inside it, with the Bash shell.

Related Post:  Install Vultr Docker Machine driver on Ubuntu 16.04 and Linux Mint 18

What I’m sure you observed with that container is how fast it took to start. As noted earlier, that’s one difference between a software container and a virtual machine instance – speed. Containers boot up really, really fast. And they can be killed just as quickly.

You’ll notice that your command prompt has changed to something like root@131a58505d2d:/#, where the string after the @ sign is the unique id of the container. So your host machine is powered by your favorite desktop flavor of Fedora 25, but you’re now operating from inside an Ubuntu container.

With command line access inside the container, you can do anything you want, like just exit the container, or do somethings more interesting, like update the package database, upgrade the system, and install any software you feel like installing. Note that because you’re operating from inside Ubuntu, the package management command is apt, not dnf. For now, you may exit the container by typing exit. In a future article, we’ll go into details of how to install applications inside a container, commit the changes, and push the new image derived from that to Docker Hub.

Let’s end this by running another container using the official Nginx image. By default, running the Nginx container will expose its ports 80 (http) and 443 (https). What this command does is map port 80 on the host machine to the equivalent port inside the container.

Mapping the port in that fashion makes it possible to access the default Nginx page by pointing your browser to the host machine’s IP address. If you did that, you should see the default Nginx page, and if you ran the command without the -d option, you should see some output indicating that the page has been accessed.

Related Post:  How to run SQL Server v.Next Public Preview on Fedora

Depending on the host machine’s resources, you can run as many containers as you want – at the same time. To search for images available on Docker Hub that you may use to run containers, type the following command:

Clean Up After Yourself

Whenever you run a container, the Docker client has to download an image from (by default) Docker Hub. The images are stored on your computer, and will remain there even after you’ve stopped or killed the container. With time, those images can take up a significant chunk of your computer’s storage space.

So a good habit to adopt is to delete those images you’ll not be using anytime soon. To list the images stored on your computer, type:

You should get an output like the following:

Don’t think you’ll be needing an image anytime soon? Delete it:

Note that a container image can be deleted only if no container is using it, so if you get an error after attempting to delete an image, first stop and/or delete the container.

Running individual Docker containers like you just read in this article is fun, but that’s just the beginning. Docker has built-in support for load balancing, orchestration, service discovery and a host of other features. I’ll be exploring those in future articles. More on Docker here

Fedora 25 GNOME 3 applications

LinuxBSDos needs your donation to continue!

I hope this article has saved you valuable time and effort to fix a problem that would have taken more time than is necessary. That makes me happy, and why I love doing this. But because more people than ever are reading articles like this with an adblocker, ad revenues have fallen to a level that's not enough to cover my operating costs. That's why I want to ask you a favor: To make a one-time or recurring donation to support this site and keep it going. It's a small favor, but every one counts. And you can make your donation using Patreon or directly via Paypal. Thank you for whatever donation you're able to make.

Donate via Patreon. Donate via Paypal.

Aside from donation, you may also signup to receive an email once I publish new content. Your email will not be shared or traded to anyone. And you can unsubscribe at any time.

Please share:

We Recommend These Vendors and Free Offers

Launch an SSD VPS in Europe, USA, Asia & Australia on Vultr's KVM-based Cloud platform starting at $5:00/month (15 GB SSD, 768 MB of RAM).

Deploy an SSD Cloud server in 55 seconds on DigitalOcean. Built for developers and starting at $5:00/month (20 GB SSD, 512 MB of RAM).

Want to become an expert ethical hacker and penetration tester? Request your free video training course of Online Penetration Testing and Ethical Hacking

Whether you're new to Linux or are a Linux guru, you can learn a lot more about the Linux kernel by requesting your free ebook of Linux Kernel In A Nutshell.


Leave a Comment

Your email address will not be published. Required fields are marked *

*