1

I am running jenkinsci/blueocean docker locally as per the instructions of running jenkins using a docker on jenkins.io. Everything seems to be working correctly but when I docker exec into the docker, I can't use sudo and I cant create a home directory for the jenkins user with an .ssh directory.

There seems to be apk package manager but if this functionality is not out of the box it makes me wonder if I am doing this wrong.

Does anyone have any experience setting up a basic ssh config on this docker image?

1

You can run an ssh server in the container as the ENTRYPOINT. It can either be started in the foreground :

ENTRYPOINT ["/usr/sbin/sshd", "-D","-p","22"]

Ensure that you have openssh installed and host keys setup.

Perhaps this Ansible role would be illustrative

| improve this answer | |
  • Thanks. Ansible is next in the learning cycle...I get what you're saying about the ENTRYPOINT. I can try that it just seems strange that this official image doesn't come with this on. As I said I'm new to Jenkins but isn't using ssh from Jenkins the sort of thing one would do from the outset. Even with what you said there is no way to create directories for the SSH keys without being able to use sudo and I'm not sure I can install sudo as the Jenkins user. All this makes me think 'this is how it works' and I'm approaching it the wrong way. Maybe install sudo as well via the ENTRYPOINT..? – tinamou_ed Jun 3 at 7:44
  • Access to the container via SSH is not what jenkins agent is designed to do - rather, it is designed to use the JNLP connection. If you really want to you can set up the ssh connection, but it requires extra work. – Bruce Becker Jun 3 at 7:50
  • I don't want to access the container with ssh I want to use ssh on the Jenkins docker to connect to a remote server to 'do something'. Is that not how Jenkins authenticates commonly to slaves? It seems strange this is taught on Linux academy in 'jenkins for beginners' if master and slave don't commonly use ssh. – tinamou_ed Jun 3 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.