Created
July 23, 2024 07:29
-
-
Save badgeek/b21678b2bc09349a79bf3011759b1b35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM cypress/base | |
| COPY . /opt/app | |
| WORKDIR /opt/app | |
| RUN npx cypress install # Install Cypress binary into image | |
| COPY . . | |
| ENTRYPOINT ["npx", "cypress", "run"] |
Author
Author
install-jenkins:
@echo "Running Jenkins Docker container..."
docker run -d --name jenkins \
-p 8080:8080 -p 50000:50000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v jenkins_home:/var/jenkins_home \
jenkins/jenkins:lts
install-docker-cli:
@echo "Installing Docker CLI in Jenkins container..."
# Access the Jenkins container
docker exec -it -u root jenkins bash -c "\
curl -fsSL https://get.docker.com -o get-docker.sh && \
sh get-docker.sh && \
usermod -aG docker jenkins && \
exit"
restart-jenkins:
@echo "Restarting Jenkins container..."
docker restart jenkins
delete-jenkins:
@echo "Deleting Jenkins container..."
docker rm -f jenkins
Author
fix-permission:
@echo "Fixing permissions for Docker socket..."
docker exec -it -u root jenkins bash -c "\
chmod 666 /var/run/docker.sock && \
exit"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To execute Docker commands inside a Jenkins Docker container, you need to set up Docker-in-Docker (DinD) or Docker-outside-of-Docker (DooD). Here's a concise guide for the DooD approach, which is generally recommended:
pipeline { agent any stages { stage('Docker Test') { steps { sh 'docker --version' sh 'docker ps' } } } }Remember to grant necessary permissions to the
/var/run/docker.sockfile on the host system if you encounter permission issues.