Skip to main content

Easy generator Dockerfile for humans.

Project description


Easy generator Dockerfile for humans

Let's use power of python for generate dockerfile!

    - all features from python: variables, multiline strings, code reuse.
    - keep all your code in one file [bash, python, conf, ...]
    - generate many docker files from one template [testing, production, ]
    - generate sequence [Dockerfile.debian => Dockerfile.python => Dockefile.yourapp, ...]
    - or if you not expert in sed, awk - you can use python for modify conf files : )

easy code, easy costomize


pip install -U pydocker


import sys
import logging
import pydocker  #


class DockerFile(pydocker.DockerFile):
    """   add here your custom features   """

d = DockerFile(base_img='debian:8.2', name='jen-soft/custom-debian:8.2')

d.RUN_bash_script('/opt/', r'''
cp /etc/apt/sources.list /etc/apt/sources.list.copy

cat >/etc/apt/sources.list <<EOL
deb jessie/updates main
deb-src jessie/updates main
deb jessie main
deb-src jessie main
deb testing main

apt-key adv --keyserver --recv-keys 04EE7237B7D453EC
apt-get clean && apt-get update

d.EXPOSE = 80
d.WORKDIR = '/opt'

# d.ENTRYPOINT = ["/opt/www-data/"]
d.CMD = ["python", "--version"]

# >_ console:

docker images

Alternative installation (without pip - from repo/master):

F=$(python -c "import site; print(site.getsitepackages()[0]+'/')")
sudo wget -v -N -O $F

Alternative usage (without installation):

try: from urllib.request import urlopen         # python-3
except ImportError: from urllib import urlopen  # python-2
d = DockerFile(base_img='debian:8.2', name='jen-soft/custom-debian:8.2')
# ...


This work is dual-licensed under Apache License 2.0 and MIT License. You can choose between one of them if you use this work.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydocker-1.0.2.tar.gz (5.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page