Jenkins-Server / Dockerfile
tuandunghcmut's picture
Create Dockerfile
55cc846 verified
# Dockerfile for Jenkins with Docker support
FROM jenkins/jenkins:lts
# Switch to root to install Docker
USER root
# Install Docker CLI and other required packages
RUN apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release \
&& curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg \
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null \
&& apt-get update \
&& apt-get install -y docker-ce-cli \
&& rm -rf /var/lib/apt/lists/*
# Switch back to Jenkins user
USER jenkins
# Install recommended Jenkins plugins
RUN jenkins-plugin-cli --plugins \
docker-workflow \
docker-commons \
docker-build-step \
docker-custom-build-environment \
docker-slaves \
docker-plugin \
blueocean \
github-branch-source \
pipeline-github-lib \
credentials-binding \
git
# Set environment variables
ENV DOCKER_HOST unix:///var/run/docker.sock
ENV JENKINS_OPTS="--httpPort=8080"
# Volume for Jenkins data persistence
VOLUME /var/jenkins_home
# Expose the default Jenkins port
EXPOSE 8080
# Health check for the container
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -sSLf http://localhost:8080/login > /dev/null