Package: dockalot
Building Docker images for the real worldIntroductiondockalotis a tool to build Docker images using Ansible playbooks for
application and configuration installation. It addresses several shortcomings
with the default Docker toolkit to make building non-trivial images easier.Using a Dockerfile is fine if you are repackaging an open source or other
publicly available package. But if you aren’t, you might have one or more
of these problems:Building your image requires credentials to a private source code or
package repositoryBuilding your image requires a custom package installation procedure more
complicated thanapt-getinstallBecause of the waydocker buildworks by building your image in layers
on top of layers, you may find that your super-secret private repository
credentials gets trapped in one of those layers. Go ahead, export an image
usingdocker saveand poke around the layers of an image you’ve already
built. Is thatyouraccess token in there? Well, it’s everyone’s access
token now…Temporary files part of any non-trivial package installation also get
trapped in those middle layers causing your final Docker image to be much
larger than they need to be. Workarounds for this problem include&&-itis;
joining dozens of shell commands together with&&in an attempt to keep
them all on the same layer. When you do this you lose the ability to add
comments in-line and your Dockerfile becomes a mess.It doesn’t have to be this way.dockalotsolves these problems by executing all of the installation
commands in one Docker layer. There are no hidden layers for credentials or
temporary files to hide in. You can focus on just installing software into
your Docker image using high-level Ansible modules and let the tools handle
the low-level details.FeaturesBuild smaller images without having to think about Docker layers.Pass your API keys into the build process and don’t worry about them
getting stuck in any hidden Docker layers.Take advantage of purpose-builtAnsible modules. Never
runsedagain!Use variables and templates in Ansible instead of clunky environment
variables.Support for most of the important Dockerfile commands. Goal is to
have feature-parity with Dockerfiles.InstallationRequirements:Python 2.7Docker >= 1.12Installdockalotusingpip:ubuntu@ubuntu-vm:~$ sudo pip install dockalotOr, to install without root access you can use avirtual environment:ubuntu@ubuntu-vm:~$ mkvirtualenv dockalot
ubuntu@ubuntu-vm:~$ . dockalot/bin/activate
(dockalot) ubuntu@ubuntu-vm:~$ pip install dockalotExample UsageA simple configuration file (example1.yml) to build an image looks like
this:---
docker:
  base_image: "python:2.7"
  entrypoint: [ "/entrypoint.py" ]
  tags:
    - myapp
---
- name: Provision the container
  hosts: all
  tasks:
    - name: Install the thing
      copy:
        dest: /entrypoint.py
        content: |
          #!/usr/bin/env python
          print("I'm a Python script")
          print("Wheeeeee!!!!")
        mode: 0755Build the image:ubuntu@ubuntu-vm:~$ dockalot example1.yml
INFO:Creating the container to provision
...
INFO:Committing the image
INFO:Created sha256:662a2be8c1215de09fc410f2c5c7fb2e8b6ed00b125c4cd27fe8a28972f8542c
INFO:Tagging image myapp:latest
ubuntu@ubuntu-vm:~$Then run your shiny new image:ubuntu@ubuntu-vm:~$ docker run myapp
I'm a Python script
Wheeeeee!!!!
ubuntu@ubuntu-vm:~$Also take a look at some morecomplex examples.LicenseThe project is licensed under the MIT license.