Docker Guide

Docker is a container manager for Linux that became quite popular. We have created an image and pushed it to Docker Hub (Dockers public image registry).

You can run a container very quickly via:

$ docker run --name petrel-test -p 8585:8585 -d apohl79/petrel

Docker will download the image, create a container named petrel-test and run it. Now you can fire a test request to petrel. If you are on linux you can just use localhost. On OS X for example you have to use the IP of your docker VM (should be 192.168.99.100 in a default installation):

$ curl "http://localhost:8585/"
<html><head><title>petrel test page</title></head><body><h1>petrel test page</h1>We got called 6 times</body></html>

Use your own code

You have two ways of using this image with your own service code:

  1. Use volumes to mount you service code into the docker container:

    $ docker run --name myservice -v /your/lua/dir:/lua:ro -p 8585:8585 -d apohl79/petrel
    

    The same way cou change petrels configuration file.

  2. Create your own image:

    1. Create a new directory and enter it

    2. Create a Dockerfile with the following content:

      FROM apohl79/petrel:latest
      COPY /your/lua/dir/ /lua/
      

      Again, if you have a different configuration, just copy it into your image to /etc/petrel/petrel.conf by using another COPY command.

    3. Now build your image:

      $ docker build -t myservice .
      
    4. And run it:

      $ docker run --name myservice -p 8585:8585 -d myservice