Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build CentOS image with ssh enabled. FAILED! #194

Open
ghost opened this issue Jul 26, 2022 · 1 comment
Open

Build CentOS image with ssh enabled. FAILED! #194

ghost opened this issue Jul 26, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 26, 2022

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!

@ghost
Copy link
Author

ghost commented Jul 26, 2022

Build docker image Success!

Just rewrite instruction on Dockerfile. from RUN to CMD.
Sorry, i'm not careless about instruction.

CMD service ssh start ; sleep infinity

But when run that image, always show error output like this:
When i start ssh with command service ssh start

Failed to get D-Bus connection: Operation not permitted

And then i rewrite Dockerfile from scratch again, follow this video.
And run again with this new image.
But error output show like this:

Failed to get D-Bus connection: No such file or directory

And ya, both of them can't i ssh from local. Error output like this:

ssh: connect to host 172.17.0.4 port 22: Connection refused

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants