Install Docker on Fedora
Warning: Do not install Docker directly with dnf unless you have configured the Docker dnf source.
Preparation
System Requirements
Docker supports the following versions of Fedora operating system:
- 38
- 39
Uninstall Old Versions
Older versions of Docker were called docker
or docker-engine
. Uninstall any old versions:
$ sudo dnf remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
dnf might report that you have none of these packages installed. Images, containers, volumes, and networks stored in /var/lib/docker/ aren't automatically removed when you uninstall Docker.
Set up the repository
Install the dnf-plugins-core package (which provides the commands to manage your DNF repositories) and set up the repository.
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
If you need the nightly or test Docker version, use the following command:
$ sudo dnf config-manager --set-enabled docker-ce-test
You can disable the nightly or test Docker version using:
$ sudo dnf config-manager --set-disabled docker-ce-test
Install Docker
Latest Docker
Update the dnf
package index and install the docker-ce
package:
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
If prompted to accept the GPG key, verify that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it.
This command installs Docker, but it doesn't start Docker. It also creates a docker group, however, it doesn't add any users to the group by default.
specific version Docker
You can also install a specific version of Docker by listing the available versions:
$ dnf list docker-ce --showduplicates | sort -r
docker-ce.x86_64 18.06.1.ce-3.fc28 docker-ce-stable
$ sudo dnf -y install docker-ce-18.06.1.ce
Install using the Convenience Script
For testing or development environments, Docker provides a convenience script to install Docker on Linux distributions. The script can also be used with the --mirror
option to use a domestic source for installation:
If you want to install the nightly build, get the script from test.docker.com
# $ curl -fsSL test.docker.com -o get-docker.sh
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
# $ sudo sh get-docker.sh --mirror AzureChinaCloud
After running the script, it will automatically do all the preparation work and install the latest stable version of Docker on your system.
Start Docker
$ sudo systemctl enable docker
$ sudo systemctl start docker
Establish the docker User Group
By default, the docker
command uses Unix sockets to communicate with the Docker engine. Only the root
user and users in the docker
group can access the Docker engine's Unix socket. For security reasons, most Linux systems do not use the root
user directly. Therefore, a better practice is to add users who need to use docker
to the docker
user group.
Create the docker
group:
$ sudo groupadd docker
Add the current user to the docker
group:
$ sudo usermod -aG docker $USER
Log out of the current terminal and log back in, then run the following test.
Test if Docker is Installed Correctly
$ docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
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/
If the above information is output correctly, the installation is successful.