If you’re using Fedora 33 and encountering the frustrating “OCI runtime create failed” error whenever you attempt to start a Docker instance, don’t worry! We have a solution for you. This tutorial will guide you through the process of creating a custom systemd service unit to resolve the issue.
Problem Description
The error message “OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:340: applying cgroup configuration for process caused: no cgroup mount found in mountinfo: unknown” often occurs when trying to launch Docker containers in Fedora 33. This error indicates a missing cgroup mount, which can prevent Docker from starting containers properly.
Temporary Solution: To temporarily resolve the issue, you can follow these steps:
- Open a terminal.
- Execute the following commands:
sudo mkdir /sys/fs/cgroup/systemd
sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd
sudo systemctl restart docker
These commands create the necessary directory and mount the cgroup, allowing Docker to restart successfully.
Permanent Solution
To ensure a permanent fix and automate the process, we will create a custom systemd service unit with the solution. This will execute the required commands during system startup. Here’s how you can do it:
Step-by-step guide
- Open a text editor and create a new file. For example, you can use the
nano
text editor:
sudo vi /etc/systemd/system/custom-init.service
- Paste the following content into the file:
[Unit]
Description=Custom Init Script
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/bash -c "if [ ! -d '/sys/fs/cgroup/systemd' ]; then mkdir /sys/fs/cgroup/systemd; fi && mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd && systemctl restart docker"
[Install]
WantedBy=multi-user.target
- Save the file and exit the text editor.
- To make systemd aware of the new service unit, run the following command:
sudo systemctl daemon-reload
- Now, you can start the service using the following command:
sudo systemctl start custom-init
This will execute the commands specified in the ExecStart
section.
If you want the script to start automatically at boot time, you can enable it using the enable
command:
sudo systemctl enable custom-init
Please note that the above script assumes you have the necessary permissions to execute the commands and mount the cgroup.
Don’t forget to collaborate commenting. Any correction correction or feedback is welcome.
Thanks.