Skip to content

Build CentOS image with ssh enabled. FAILED! #194

@ghost

Description

This is my Dockerfile

FROM centos:7
RUN yum install -y initscripts openssh-server vim
RUN echo 'root:pass' | chpasswd
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -i 's/#Port 22/Port 22/' /etc/ssh/sshd_config
RUN service ssh start ; sleep infinity
EXPOSE 22

I install initscripts follow with this instruction for service command but not work anymore while building. Like below.

Error output when building image

Step 6/7 : RUN service ssh start ; sleep infinity
 ---> Running in b3a8b35f13b6
Redirecting to /bin/systemctl start ssh.service
Failed to get D-Bus connection: Operation not permitted

I know that systemd can't run on docker. But, how to solve this?
Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions