Open Treverix opened 8 years ago
I ran across this when trying to solve a similar DBUS problem
https://github.com/CentOS/sig-cloud-instance-images/issues/41
Hope it helps
@Treverix I am having the same problem. Have you solved this? Thanks.
Not sure but most instructions about centos and systemd in docker out outdated. See this for current working instructions: https://github.com/docker/docker/issues/28614#issuecomment-261724902
I don't think you can run services via systemd in a docker build. Special privileges are needed. You can only enable / disable services, e.g.:
RUN systemctl enable dnsmasq
If you need to run apache during the build maybe you could instead run it in foreground:
RUN apachectl -D FOREGROUND & sleep 30 && curl -i localhost
If you need your container startup CMD to run a bash script before starting systemd init (e.g. to do some configuration based on env variables), that works if the script ends by calling exec /usr/sbin/init
.
I'm having the same problem, on OSX 10.11.6 (El Capitan). Docker version 1.11.1, build 5604cbe.
My app is trying to start up Postgres 9.5.
Running:
docker run -i -t \
--privileged \
-p 80:3000 \
--cap-add SYS_ADMIN \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
--dns 4.4.4.4 --dns 8.8.4.4 \
-e NODE_ENV="${NODE_ENV}" \
tmarshall/latest bash;
My Dockerfile builds off of the same given in https://hub.docker.com/_/centos/ (see "Dockerfile for systemd base image").
There was also an older thread that mentioned a fix for Ubuntu users, which I tried to apply to OSX, via -v $(mktemp):/run
but that did not help.
No matter what, I always get
Redirecting to /bin/systemctl start postgresql-9.5.service
Failed to get D-Bus connection: Operation not permitted
^ I got it to work by referring to @zokeber's repo, docker-postgresql
I can run systemd
in Centos 7 with this command:
docker run --tmpfs /run -v /sys/fs/cgroup:/sys/fs/cgroup:ro -d centos:7 /sbin/init
More references:
please refer https://github.com/docker-library/docs/issues/1177
When trying to build an image based on this Dockerfile:
the last step fails:
The lines below the systemd comment have been copied from the docs today (see reference in the comment)