Author Topic: Quick tutorial on how to build RPM for Docker on Fedora 33  (Read 3364 times)

tle

  • Sr. Member
  • ****
  • Posts: 462
  • Karma: +53/-0
    • View Profile
    • Trung's Personal Website
Quick tutorial on how to build RPM for Docker on Fedora 33
« on: March 13, 2021, 08:04:32 am »
Docker CE version 19 or 20 RPMs are not officially available but it does not mean you could not build the RPM packages from the SRPM.

1) Install latest golang and rpmbuild
2) Download the latest SRPM of docker from https://download.docker.com/linux/fedora/33/source/stable/Packages/
3) Execute following commands:

Code: [Select]
$ sudo dnf install -y rpmbuild golang make
$ sudo su # switch to root
$ export GOPATH=/go
$ export GOOS=linux
$ export GOARCH=ppc64le
$ export PATH=/go/bin:$PATH
$ rm -rf /go # clean up

$ go get -v github.com:cpuguy83/go-md2man # required to build docker-ce-cli
$ rpmbuild -D "_version 20.10.5" -D "_release 0" -D "_gitcommit_cli 55c4c88" -D "_origversion 20.10.5" --rebuild docker-ce-cli-20.10.5-3.fc33.src.rpm


$ rpm2cpio docker-ce-20.10.5-3.fc33.src.rpm | cpio -
$ sed -i 's/%{_version}/20.10.5/g' docker-ce.spec
$ sed -i 's/%{_release}/0/g' docker-ce.spec
$ sed -i 's/%{_origversion}/20.10.5/g' docker-ce.spec
$ sed -i 's/%{_gitcommit_cli}/55c4c88/g' docker-ce.spec
$ sed -i 's/%{_gitcommit_engine}/363e9a8/g' docker-ce.spec
$ sed -i 's/containerd.io/containerd/g' docker-ce.spec
$ fedpkg --release f33 local
$ mv ppc64le/docker-ce-20.10.5-0.fc33.ppc64le.rpm /root/rpmbuild/RPMS/ppc64le/
$ rpm -i /root/rpmbuild/RPMS/ppc64le/docker-ce-20.10.5-0.fc33.ppc64le.rpm
$ sudo rpmbuild --rebuild docker-ce-rootless-extras-20.10.5-3.fc33.src.rpm
$ cd /root/rpmbuild/RPMS/ppc64le
$ dnf install -y containerd libcgroup
$ rpm -i docker-ce-*.rpm

If you are lazy, just grab my RPMs at https://github.com/runlevel5/docker-ppc64le-rpms

Please note, as the time of this writing the latest available RPM of runc on FC33 is runc-1.0.0-279.dev.gitdedadbf.fc33 which _DOES NOT_ support cgroupv2 so you would run into error OCI does not support cgroupv2. To workaround this issue, I would highly recommend you compile `runc` from the source code and move it manually to /usr/bin/runc. OR download the rpm I built in https://github.com/runlevel5/docker-ppc64le-rpms
Let's hope that Fedora team would prepare another update for the runc

Optional:

By default, docker would use runc for runtime. However you could configure it to run with crun instead by modifying following file:

Code: [Select]
$ cat /etc/docker/daemon.json
{
  "default-runtime": "crun",
  "runtimes": {
     "crun": {
       "path": "/usr/local/bin/crun"
    }
  }
}

Once done, simple reload the daemon:

Code: [Select]
$ sudo systemctl daemon-reload
$ sudo systemctl start docker.service

to verify run

Code: [Select]
$ docker version

Server:
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.15.8
  Git commit:       363e9a8
  Built:            Sat Mar 13 15:07:53 2021
  OS/Arch:          linux/ppc64le
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:       
 crun:
  Version:          0.18
  GitCommit:        808420efe3dc2b44d6db9f1a3fac8361dde42a95
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

The output should show the version info of crun instead of runc


If you run into error like:

Code: [Select]
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied

The quick fix is to update the permission:

Code: [Select]
$ sudo chmod 666 /var/run/docker.sock

Enjoy :)
« Last Edit: March 17, 2021, 02:25:23 am by tle »
Faithful Linux enthusiast

My Raptor Blackbird