This is an old revision of the document!


How to install and test Docker and friends on current Fedora 29.

Fedora's Docker packaging has undergone some reorganization, so you first need to get rid of all earlier Docker-related packages. First, take a quick look at what Docker-related packages are already installed:

$ rpm -qa "*docker*"
docker-ce-17.12.1.ce-1.fc27.x86_64
python3-dockerpty-0.4.1-7.fc27.noarch
docker-compose-1.17.1-1.fc27.noarch
python3-docker-pycreds-0.2.1-5.fc27.noarch
python3-docker-2.6.1-1.fc27.noarch
$

If you see older packages, then remove them before going any further:

$ 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
$

or possibly just:

$ sudo dnf remove "*docker*"

The easiest way to install the new Docker packages for Fedora is to register the Docker repository containing those packages. First, install the DNF plugin to manage repositories from the command line:

$ sudo dnf install dnf-plugins-core

Next, register the Docker repository by running:

$ sudo dnf config-manager \
    --add-repo \
    https://download.docker.com/linux/fedora/docker-ce.repo

To verify that this worked, query that repo -- you should see something like this:

$ dnf repoquery --repo=docker-ce-stable
containerd.io-0:1.2.2-3.fc29.x86_64
docker-ce-3:18.09.1-3.fc29.x86_64
docker-ce-cli-1:18.09.1-3.fc29.x86_64
$

At this point, you can install Docker (and Docker Compose if you wish):

$ sudo dnf install docker-ce docker-compose

resulting in:

Installing:
 containerd.io         x86_64         1.2.2-3.fc29              docker-ce-stable
     replacing  runc.x86_64 2:1.0.0-66.dev.gitbbb17ef.fc29
 docker-ce             x86_64         3:18.09.1-3.fc29          docker-ce-stable
Installing dependencies:
 docker-ce-cli         x86_64         1:18.09.1-3.fc29          docker-ce-stable
 libcgroup             x86_64         0.41-20.fc29              fedora
if [ $1 -gt 0 ] ; then
    # package upgrade scenario, before new files are installed

    # clear any old state
    rm -f /var/lib/rpm-state/docker-is-active > /dev/null 2>&1 || :

    # check if docker service is running
    if systemctl is-active docker > /dev/null 2>&1; then
        systemctl stop docker > /dev/null 2>&1 || :
        touch /var/lib/rpm-state/docker-is-active > /dev/null 2>&1 || :
    fi
fi
if [ $1 -eq 1 ] ; then 
        # Initial installation 
        systemctl --no-reload preset docker &>/dev/null || : 
fi 

if ! getent group docker > /dev/null; then
    groupadd --system docker
fi
... EE stuff snipped ...
if [ $1 -eq 0 ] ; then
        # Package removal, not upgrade
        systemctl --no-reload disable --now docker &>/dev/null || :
fi

update-alternatives --remove dockerd /usr/bin/dockerd || true
if [ $1 -ge 1 ] ; then
        # Package upgrade, not uninstall
        systemctl try-restart docker &>/dev/null || :
fi
$ systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://docs.docker.com
$
$ sudo systemctl enable docker
$ sudo systemctl start docker

and verify that it's running with:

$ systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-01-24 05:45:18 EST; 6s ago
     Docs: https://docs.docker.com
 Main PID: 16470 (dockerd)
    Tasks: 46
   Memory: 58.3M
   CGroup: /system.slice/docker.service
           ├─16470 /usr/bin/dockerd -H fd://
           └─16496 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
$
$ sudo docker run hello-world

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://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/
$

The installation of docker-ce should have created a new group named docker, and if you want to run Docker images without the constant need for sudo, simply add your username to that group:

$ sudo usermod -aG docker your-username

then log out and log in again, and verify that you're a member of the docker group with:

$ id
uid=1000(rpjday) gid=1000(rpjday) groups=1000(rpjday),967(docker) ...
                                                          ^^^^^^
$

At this point, you should be able to run the Hello, World image without root privilege:

$ docker run hello-world
... etc etc ...
  • docker_installation_on_fedora.1548326873.txt.gz
  • Last modified: 2019/01/24 10:47
  • by rpjday