How do I run a Docker container that uses SystemD from the latest version of Ubuntu (18.10)?

社会主义新天地 提交于 2020-01-15 10:28:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!