Skip to content

millosh/docker-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-tools

My Docker tools

For now just one tool, named "bootstrap-docker.py".

Requirements

Besides Python 2.x, you will need "simplejson" module.

bootstrap-docker.py

A tool is very primitive. In the future, I will normalize sys.argv part.

Presently, it works just with debootstrap, meaning that you can relatively easily to upgrade it for all Debian-based distributions. However, at the moment, the script as-is supports just Debian jessie, testing, unstable and experimental. In the future I'll add support for RPM-based distributions.

If you find this micro-tool useful and want to contribute or comment, please let me know: [email protected].

Arguments

--bootstrap-release. Conditionally optional. If the varialbe has been
  defined inside of the "distros config", then you do not need to use
  it.  Otherwise you have to define it.  The initial usage was for
  Debian experimental, which is Debian unstable with experimenal
  repository and thus requires "unstable" here.  However, it could be
  useful if you want to create your own non-default additions into the
  filesystem.

  In other words, it's useful for grouping types of Docker
  containers. "This is Apache docker container and it requres Apache
  /etc structure." -- and similar. In that case, you will say that the
  variable --release is not "jessie" or "testing", but, for example,
  "apache2.4", create the filesystem structure inside of
  system/debian/apache2.4, while you will define --bootstrap-release as
  "jessie" or "testing".

--distro: Mandatory.  Distribution.  It works just with Debian-based
  distributions.  As debootstrap doesn't use this, you could use
  whichever string you want.

--distros-config: Optional.  Two arguments inside of the JSON file which
  define Docker repository and "bootstrap release" (see
  --bootstrap-release).  You have the example inside of the file
  "distros.json". Will be used for more variables in the future. If you
  do not define it, arguments --docker-repository and
  --bootstrap-release will be mandatory.

--docker-repository: Conditionally optional. If the variable has been
  defined inside of the "distros config", then you do not need to use
  it. If you are not uploading the docker container into the repository, 
  this variable is mandatory, but it could be an arbitrary string.
  Defines docker repository where you want to upload your image.

--full-init: Optional.  If you are fine with program not doing anything;
  otherwise conditionally optional: one of the following commands should
  be invoked: --full-init, --init, --full-update, --update.

  This option is doing the following: system_install (debootstrap
  installation in chroot), config_update (minimal config update,
  including copying the files from system/<distribution>/<release>/
  path), update_software (apt-get update, aptget-upgrade -y),
  install_software (install additional software; at the moment, the
  script itself is defining installation of vim-nox, tcpdump, nmap,
  net-tools; in the future, a separate configuration file will be used
  for that), create_docker_image (imports the content of particular
  chroot directory into docker image), push_to_cloud (pushing docker to
  docker repository), run_docker (run docker image).

--full-update: Optional.  If you are fine with program not doing
  anything; otherwise conditionally optional: one of the following
  commands should be invoked: --full-init, --init, --full-update,
  --update.

  This option is doing the following: update_software (apt-get update,
  aptget-upgrade -y), create_docker_image (imports the content of
  particular chroot directory into docker image), push_to_cloud (pushing
  docker to docker repository).

--init: Optional.  If you are fine with program not doing anything;
  otherwise conditionally optional: one of the following commands should
  be invoked: --full-init, --init, --full-update, --update.

  This option is doing the following: system_install (debootstrap
  installation in chroot), config_update (minimal config update,
  including copying the files from system/<distribution>/<release>/
  path), update_software (apt-get update, aptget-upgrade -y),
  install_software (install additional software; at the moment, the
  script itself is defining installation of vim-nox, tcpdump, nmap,
  net-tools; in the future, a separate configuration file will be used
  for that), create_docker_image (imports the content of particular
  chroot directory into docker image), run_docker (run docker image).

--noexec: Optional.  Dry run.  Default is to execute the commands.

--noprint: Optional.  Do not print the commands.  Default is to print
  the commands.

--packages: Optional.  Comma-sepparated list of the additional software
  you want to install in addition or not to the defined list of software
  inside of the JSON file (see: --software-config).

--root: Optional. Root dir, where you can find "system" directory and where
  "chroots" directory will be created.  If not defined, will be current
  directory.

--release: Mandatory. Distribution release, like "jessie", "testing". It
  will be sent to debootstrap, so everything what debootstrap support,
  this program supports, as well (Ubuntu, Mint etc.  releases).

--software-config: Optional.  The list of the software you want to be
  added after the initial installation.  JSON file;
  "software/software.json" is an example for the structure (simple
  array).

--tag: Optional.  Will tag docker image and docker container.  If not
  defined, it will be "default".

--update: Optional.  If you are fine with program not doing anything;
  otherwise conditionally optional: one of the following commands should
  be invoked: --full-init, --init, --full-update, --update.

  This option is doing the following: update_software (apt-get update,
  aptget-upgrade -y), create_docker_image (imports the content of
  particular chroot directory into docker image).

Approach

This tool creates and updates chroot'd Debian installation and imports it into the Docker image. The main reason for this approach is to make as less images layers as it's possible.

I suggest the following approach:

  • Initialize the container and push it into the repository (--full-init).
  • Update chroot periodically and push into the repository (--full-update).

Examples

Dry run:

./bootstrap-docker.py --noexec --distro debian --release jessie --docker-repository millosh/debian-jessie --bootstrap-release jessie --full-init

Full init:

./bootstrap-docker.py --distro debian --release jessie --docker-repository my_docker_repo/debian-jessie --bootstrap-release jessie --full-init

Full update:

./bootstrap-docker.py --distro debian --release jessie --docker-repository my_docker_repo/debian-jessie --bootstrap-release jessie --full-update

Issues

Inside of system/all/etc/ you will find the file resolv.conf. If your network settings do not allow using Google DNS servers, you should either remove the file and implicitly use resolv.conf from your host machine or define explicitly which DNS servers you want to use.

Releases

No releases published

Packages

No packages published

Languages