-1

I am trying to add ssh to my dockerfile and locally the container runs fine. but on jenkins k8s cluster it fails to come up and exits. any hint? error

Defaulted container "main" out of: main, jnlp
exec /sbin/tini: no such file or directory
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends \
      build-essential \
      ca-certificates \
      curl \
      git \
      fuse \
      openjdk-11-jdk-headless \
      ssh

ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini
RUN chmod +x /sbin/tini

pod yaml on jenkins is

apiVersion: v1
kind: Pod
spec:
  imagePullSecrets:
  - name: artifactory-creds
  containers:
  - name: main
    image: artifactory.team/ssh-05ba8e
    securityContext:
      capabilities:
        add:
        - SYS_ADMIN
      privileged: true
      runAsUser: 0
      procMount: Default
    command:
    - /sbin/tini
    args:
    - --
    - sleep
    - infinity

jenkinsfile

        stages {
            stage('Formatting and Style') {
                agent {
                    label 'ssh-pod'
                }
                when { expression { !params.Refresh } }
                steps {
                    container('main') {
                        sh 'echo "using image with SSH Agent\n"'
                            checkoutUtil(
                                credentialsId: 'git-ssh',
                                remoteUrl: "$REPO_MIRROR_URL",
                                branch: 'main'
                            )
                        }
2
  • Wrong image? Replace /sbin/tini with sleep and check if you can see it with ls.
    – Iterokun
    Commented Jul 9 at 6:55
  • the issue was I was building on new Mac M2 and that required me to specify --platform in dockerfile and then it worked on linux. shall I post as answer or close ? FROM --platform=linux/amd64 ubuntu:20.04
    – AhmFM
    Commented Jul 9 at 23:22

1 Answer 1

0

When building on Apple Mac M3 Pro Chip, locally I had to call out in Dockerfile FROM --platform=linux/amd64 ubuntu:20.04 which then ran fine on lunux k8s container pod spin via jenkins deploy.

so resulting file is below when building on a mac m3

FROM --platform=linux/amd64 ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends \
      build-essential \
      ca-certificates \
      curl \
      git \
      fuse \
      openjdk-11-jdk-headless \
      ssh

ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini
RUN chmod +x /sbin/tini

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