[Docker] Install Docker and Docker Compose on Linux Fedora

Install Docker and Docker Compose on Linux Fedora

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.

Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.

Fedora Linux is a Linux distribution developed by the Fedora Project which is sponsored primarily by Red Hat (an IBM subsidiary) with additional support and sponsors from other companies and organizations. Fedora contains software distributed under various free and open-source licenses and aims to be on the leading edge of open-source technologies. Fedora is the upstream source for Red Hat Enterprise Linux.

Install Docker

To get started with Docker Engine on Fedora, make sure you meet the prerequisites, then install Docker.

Prerequisites

OS requirements

To install Docker Engine, you need the 64-bit version of one of these Fedora versions:

  • Fedora 34

  • Fedora 35

Install using the repository

Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.

Set up the repository

Install the dnf-plugins-core package (which provides the commands to manage your DNF repositories) and set up the stable repository.

1
2
3
4
5
6
7
8
9
10
[root@fedora ~]# sudo dnf -y install dnf-plugins-core
sudo dnf config-manager \
--add-repo \
https://download.docker.com/linux/fedora/docker-ce.repo
Last metadata expiration check: 0:40:43 ago on Wed 30 Mar 2022 01:52:51 AM UTC.
Package dnf-plugins-core-4.1.0-1.fc35.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Adding repo from: https://download.docker.com/linux/fedora/docker-ce.repo

Install Docker Engine

  1. Install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
1
[root@fedora ~]# sudo dnf install docker-ce docker-ce-cli containerd.io
  1. Start Docker.
1
[root@fedora ~]# sudo systemctl start docker
  1. Verify that Docker Engine is installed correctly by running the hello-world image.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[root@fedora ~]# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:bfea6278a0a267fad2634554f4f0c6f31981eea41c553fdf5a83e95a41d40c38
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/
  1. Check Docker version:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$ sudo docker version
Client: Docker Engine - Community
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:48:41 2022
OS/Arch: linux/amd64
Context: default
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.14
API version: 1.41 (minimum version 1.12)
Go version: go1.16.15
Git commit: 87a90dc
Built: Thu Mar 24 01:46:30 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.5.11
GitCommit: 3df54a852345ae127d1fa3092b95168e4a88e2f8
runc:
Version: 1.0.3
GitCommit: v1.0.3-0-gf46b6ba
docker-init:
Version: 0.19.0
GitCommit: de40ad0

Install Docker Compose

On Linux, you can download the Docker Compose binary from the Compose repository release page on GitHub. Follow the instructions from the link, which involve running the curl command in your terminal to download the binaries. These step-by-step instructions are also included below.

Run this command to download the current stable release of Docker Compose:

1
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Apply executable permissions to the binary:

1
$ sudo chmod +x /usr/local/bin/docker-compose

Test the installation.

1
2
3
4
5
[root@fedora ~]# docker-compose version
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019

References

[1] Install Docker Compose | Docker Documentation - https://docs.docker.com/compose/install/#install-compose-on-linux-systems

[2] Install Docker Engine on Fedora | Docker Documentation - https://docs.docker.com/engine/install/fedora/

[3] Fedora - https://getfedora.org/