vagrant2docker2jenkins-small

Nginx proxy for a Jenkins container

25 May, 2015

As a Mac user, Docker comes in as boot2docker. I don’t quite like using that interface but I prefer having a simple Ubuntu VM on my Vagrant environment where I can manage my containers from a pre-installed Docker. I like this arrangement because it allows me to keep updated on Vagrant, which is more useful for various environments and providers: VirtualBox, VMware, Docker and Hyper-V. I chose Jenkins for this example:

vagrant2docker2jenkins

At the end of the line I have a default Jenkins container running and publishing at port 8080. To be able to see it from my Mac browser I need to forward ports from Vagrantfile (8080 to 80) then Nginx (80 to 8080):

http://localhost:8080 >> ubuntu:80 >> jenkins:8080
config.vm.network "forwarded_port", host: 8080, guest: 80, auto_correct: true
  • @ Ubuntu
$ apt-get -y install docker nginx
$ docker rm jenkins1
$ docker run -d -p 8080:8080 --name=jenkins1 jenkins
$ docker inspect jenkins1 | grep IPAddress
  "IPAddress": "172.17.0.1",
  • @ Nginx configuration in Ubuntu
$ wget https://gist.githubusercontent.com/carlessanagustin/f34db6dc45e376029682/raw/0622f8f375d4ba68e49350dc941198345c52bbe6/nginx-reverse-proxy.conf
  (Replace server IP from nginx-reverse-proxy.conf)
$ cp nginx-reverse-proxy.conf /etc/nginx/sites-enabled/jenkins
$ service nginx restart

    Tags: , , , , , , ,

    Leave a Comment