Installing Docker Engine on Fedora

Uninstall old versions

Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.

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

Set up the dnf 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

Install Docker Engine

  1. Install the latest version of Docker Engine, containerd, and Docker Compose or go to the next step to install a specific version:

    sudo dnf install docker-ce docker-ce-cli containerd.io 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.

  2. To install a specific version of Docker Engine, list the available versions in the repo, then select and install:

    a. List and sort the versions available in your repo. This example sorts results by version number, highest to lowest, and is truncated:

    ~]$ dnf list docker-ce  --showduplicates | sort -r

    docker-ce.x86_64 3:18.09.1-3.fc28 docker-ce-stabledocker-ce.x86_64 3:18.09.0-3.fc28 docker-ce-stabledocker-ce.x86_64 18.06.1.ce-3.fc28 docker-ce-stabledocker-ce.x86_64 18.06.0.ce-3.fc28 docker-ce-stable

    The list returned depends on which repositories are enabled, and is specific to your version of Fedora (indicated by the .fc28 suffix in this example).

    b. Install a specific version by its fully qualified package name, which is the package name (docker-ce) plus the version string (2nd column) up to the first hyphen, separated by a hyphen (-), for example, docker-ce-3:18.09.1.

    sudo dnf -y install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-compose-plugin

    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.

  3. Start Docker.

    sudo systemctl start docker
  4. Verify that Docker Engine is installed correctly by running the hello-world image.

    sudo docker run hello-world

    This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.

This installs and runs Docker Engine. Use sudo to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.

Uninstall Docker Engine

  1. Uninstall the Docker Engine, CLI, Containerd, and Docker Compose packages:

    sudo dnf remove docker-ce docker-ce-cli containerd.io docker-compose-plugin
  2. Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:

    sudo rm -rf /var/lib/docker
    sudo rm -rf /var/lib/containerd

You must delete any edited configuration files manually.

Troubleshooting

Issue: docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).

Workaroud:

sudo tee /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://docker.registry.cyou",
"https://docker-cf.registry.cyou",
"https://dockercf.jsdelivr.fyi",
"https://docker.jsdelivr.fyi",
"https://dockertest.jsdelivr.fyi",
"https://mirror.aliyuncs.com",
"https://dockerproxy.com",
"https://mirror.baidubce.com",
"https://docker.m.daocloud.io",
"https://docker.nju.edu.cn",
"https://docker.mirrors.sjtug.sjtu.edu.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.iscas.ac.cn"
]
}
EOF

sudo systemctl daemon-reload
sudo systemctl restart docker

Reference:

Setting Docker Register Mirrors