Hi, I’m running Jenkins for MacOS (using Homebrew) and Docker Desktop on Mac.
When I try to build docker image for Python app from Jenkins pipeline, the following error is reported:
+ docker build -t <docker image name> .
ERROR: mkdir /.docker: permission denied
Jenkinsfile snippet:
pipeline {
agent none
stages {
...
stage("Build Docker Image") {
agent {
docker { image 'docker:24.0.5' }
}
steps {
script {
dockerImage = docker.build("<docker image name>:${env.BUILD_ID}")
}
}
}
...
}
}
Dockerfile (from root path on GitHub repository):
FROM python:alpine3.18
WORKDIR /app
COPY requirements.txt /app
RUN pip install -r requirements.txt
EXPOSE 5000
COPY . /app
CMD ["flask", "run","--host","0.0.0.0","--port","5000"]
In previous stages, docker containers are successfully used.
EDIT:
I needed to apply this workaround: How to Setup Docker in Jenkins on Mac - Harshit Yadav - Medium because I have faced docker command not found
issue before this one.
I assume that the user for Jenkins does not have permissions to write in ./docker dir but I’m not sure which user this is.
Every help is welcome. Thank you in advance for your time.