Easy, compact, shortest Docker commands : edjanger

Tired about repeating docker commands with long parameters ?

Trying to find magic one from history. Putting commands in some exotical scripts ?

Try edjanger !

Edjanger purpose is to give simple and shortest commands for docker beginners. There is no intention to replace docker-compose. Objective is to reduce time to write long commands with many options and to give a standard way (edjanger.properties) to store them. Standard use case is to work on a single Docker container configuration. When containers configuration process is done, you could produce a docker-compose.yaml with edjangercompose command. Edjanger had a command (edjangertemplate) allowing to provide many configuration for the same container (allowing to define many different ports or shared volume configuration or other options for integration or production or any others...)

Demo with an httpd server configuration.

mkdir webserver
cd webserver
edjangerinit --template=demo_httpd

Install

Prerequisities for installation

  • git
  • zip

Prerequisities for runtime

  • gettext (for envsubst)
  • bc (optional)

Checked compatibility

  • os x El Capitan 10.11.6
  • Linux ubuntu > 14.04

Installation

Define path where to install edjanger (variable EDJANGER_INSTALL_PATH). Following commands are given as example.

EDJANGER_INSTALL_PATH=/opt/edjanger
git clone https://github.com/pamtrak06/edjanger.git $EDJANGER_INSTALL_PATH
cd $EDJANGER_INSTALL_PATH; chmod 755 scripts/*.sh; chmod 755 edjangerinstall.sh

This will install edjanger in /opt/edjanger If installation fail to install in this directory, try to install it in another, see Linux Filesystem Hierarchy Standard for potential paths.

Run edjanger installation

./edjangerinstall.sh --alias

Execute the generated alias file:

. /usr/local/bin/edjanger/edjanger.alias

All is done !!! Run this command to see your edjanger aliases

alias|grep edjanger

Following configuration chapter explain how to "fix" alias in shell environement.

Configuration

~bash~

Bash as login shell will load /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile in the order Bash as non-login interactive shell will load ~/.bashrc Bash as non-login non-interactive shell will load the configuration specified in environment variable $BASH_ENV

Add lines at the bottom of one of the following files:

echo "source {edjanger path}/edjanger.alias" >> /etc/profile

or

echo "source {edjanger path}/edjanger.alias" >> ~/.bash_profile

or

echo "source {edjanger path}/edjanger.alias" >> ~/.bash_login

or

echo "source {edjanger path}/edjanger.alias" >> ~/.profile

or

echo "source {edjanger path}/edjanger.alias" >> ~/.bashrc

or

echo "source {edjanger path}/edjanger.alias" >> ~/.bash_aliases

zsh

Add lines at the bottom of the file ~/.zshrc

echo "source {edjanger path}/edjanger.alias" >> ~/.zshrc

ksh

Add lines at the bottom of the file ~/.profile

echo "source {edjanger path}/edjanger.alias" >> ~/.profile

bourne

Add lines at the bottom of the file ~/.profile

echo "source {edjanger path}/edjanger.alias" >> ~/.profile

csh or tcsh

Add lines at the bottom of the file ~/.login

echo "source {edjanger path}/edjanger.alias" >> ~/.login

Uninstall

Remove edjanger aliases by executing:

source edjanger.unalias

Remove references to source command in ~/.bash_aliases

vi ~/.bash_aliases

Remove edjanger files

rm -rf {edjanger path}/

Getting started

Create a new edjanger working project :

edjangerinit

File edjanger.properties contain variables used for all edjanger commands.

Type edjanger command and --help to know parameters read from command and available arguments.

You could use a teplate file to configure edjanger.properties.

To do this, create a properties file (given at init is configuration.properties) which contain variables to be replaced in edjanger.template to produce edjanger.properties.

See following example.

edjangerinit --template=httpd

Example with jenkins

Initialize you project

mkdir jenkins && cd jenkins && edjangerinit

Configure your configuration.properties with correct parameters.

vi configuration.properties
export app_image_name="test/jenkins"
export app_container_name="jenkins"
export app_exposed_ports="-p 8080:8080 -p 50000:50000"
export app_shared_volumes="-v \$PWD/volumes/jenkins_home:/var/jenkins_home"
#export app_environment_variables="-e <variable name 1>=<value 1> -e <variable name 2>=<value 2>"

Configure your edjanger.template with correct parameters. Comment lines containing environment_variables and container_hostname.

vi edjanger.template
#environment_variables="${app_environment_variables}"
#container_hostname="${app_container_hostname}"

Update Dockerfile with jenkins reference from docker hub

touch build/Dockerfile
echo "FROM jenkins:latest" > build/Dockerfile

Run template to produce edjanger.properties

edjangertemplate properties=configuration

Example 1: docker build

edjangerbuild

instead of:

docker build -t "test/jenkins"       build

Example 2: docker run

edjangerrun

instead of:

docker run -dt --name jenkins_1    -p 8080:8080 -p 50000:50000  -v $PWD/jenkins/volumes/jenkins_home:/var/jenkins_home

Example 3: docker stop

edjangerstop

instead of:

docker stop $(docker ps -aq | grep "test/jenkins")

Best practices

Use a folder for each edjanger project.

Use following structure :

- [edjanger main project folder]
    - edjanger.properties   > edjanger project configuration
    - [build]               > docker build folder (contains Dockerfile and files dependencies)
        -  Dockerfile       > default Dockerfile
    - volumes               > contains all shared volumes

Help

For each commands, see edjangerhelp 'command' for list of parameters read in edjanger.properties and arguments.

Unit tests

Tests use following

Result Tests are visible here

Run tests :

cd [edjanger path];
./run_tests.sh