问题
I'm trying to execute a Docker image built using 'ubuntu:latest' and I keep getting SystemD error messages when I run the container:
System has not been booted with systemd as init system (PID 1). Can't operate.
If I try this solution and spawn the container using docker run -it -e container=docker your-image-name /sbin/init, I get the following error:
Failed to mount tmpfs at /run: Operation not permitted
Failed to mount tmpfs at /run/lock: Operation not permitted
[!!!!!!] Failed to mount API filesystems, freezing.
Freezing execution.
What should I try differently?
回答1:
You can solve this using a different version, like 16.04:
docker run -d \
-h ubuntu \
--name ubuntu \
--privileged \
docker.io/library/ubuntu:16.04 /sbin/init
After run, you can accessed using the follow command:
docker exec -it ubuntu /bin/bash
This version uses systemd
.
回答2:
Upgrade to Ubuntu Bionic and try /sbin/init
method
来源:https://stackoverflow.com/questions/53750952/how-do-i-run-a-docker-container-that-uses-systemd-from-the-latest-version-of-ubu