- You should have docker properly installed on your machine.
- First, pull the official jenkins image from Docker repository.
docker pull jenkins
- Next, run a container using this image and map data directory from the container to the host;
In the example below /var/jenkins_home from the container is mapped to jenkins/ directory from the current path on the host. Jenkins 8080 port is also exposed to the host as 49001.
docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home:z -t jenkins/jenkins
Addtionally, you can configure nginx as a reverse proxy to your Jenkins instance, e.g:
upstream app {
server 127.0.0.1:49001;
}
server {
listen 80;
server_name jenkins.your-domain.com;
location / {
proxy_pass http://app;
}
}