I have the following docker compose configuration:
version: '3.3'
services:
jenkins:
image: jenkins-ansible
build: ansible
restart: on-failure
privileged: true
user: root
ports:
- 8080:8080
- 5000:5000
container_name: jenkins
volumes:
- /home/juliano/workspace/docker-projects/jenkins/volume/:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/local/bin/docker:/usr/local/bin/docker
jenkins-agent-1:
build:
context: jenkins-agent
restart: on-failure
expose:
- "22"
container_name: jenkins-agent-1
environment:
- JENKINS_AGENT_SSH_PUBKEY=ssh-rsa omitted
- JAVA_HOME=/opt/java/openjdk/bin/java
depends_on:
- jenkins
volumes:
- /home/juliano/workspace/docker-projects/jenkins/volume/:/var/jenkins_home
jenkins-agent-2:
# image: jenkins/ssh-agent:jdk11
build:
context: jenkins-agent
restart: on-failure
expose:
- "22"
container_name: jenkins-agent-2
environment:
- JENKINS_AGENT_SSH_PUBKEY=ssh-rsa omitted
- JAVA_HOME=/opt/java/openjdk/bin/java
depends_on:
- jenkins
volumes:
- /home/juliano/workspace/docker-projects/jenkins/volume/:/var/jenkins_home
remote_host:
container_name: remote-host
image: remote-host
build:
context: ubuntu18.04
And I'm receiving the following error message:
+ env
+ [[ ssh-rsa omitted == ssh-* ]]
+ write_key 'ssh-rsa omitted'
+ local ID_GROUP
++ stat -c %U:%G /home/jenkins
+ ID_GROUP=jenkins:jenkins
+ mkdir -p /home/jenkins/.ssh
+ echo 'ssh-rsa omitted'
+ chown -Rf jenkins:jenkins /home/jenkins/.ssh
+ chmod 0700 -R /home/jenkins/.ssh
+ [[ '' == ssh-* ]]
+ env
+ grep _
/usr/local/bin/setup-sshd: line 54: /etc/environment: Permission denied
The jenkins-agent dockerfile is:
FROM jenkins/ssh-agent
USER root
RUN apt-get update && apt-get install python3 -y
RUN apt-get install curl -y
RUN apt-get install python3-distutils -y
RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
python3 get-pip.py && \
pip install ansible --upgrade
USER jenkins
Previously, I was using jenkins/ssh-agent:jdk11 to build the agents and it was working well. Then I unsuccessfully tried to install Ansible into the agents through the jenkins-agent Dockerfile (receiving the aforementioned error). Now, even if I change jenkins-agent to jenkins/ssh-agent:jdk11, it is incurring the same problem.
Anyone could kindly help me, please?