ds
- Docker Scripts
ds [-x] [@<container>] <command> [<arg>...]
DockerScripts is a shell script framework for Docker.
Each container is like a virtual machine that has an application
installed inside. Each container has a base directory where the
settings of the container are stored (in the file
settings.sh
). The command ds
picks the parameters that it needs
from the file settings.sh
in the container's directory.
Normally the commands are issued from inside the container's
directory, however the option @<container>
can be used to specify
the context of the command.
The option -x
can be used for debugging.
pull <app> [<branch>]
Clone or pull https://gitlab.com/docker-scripts/<app>
to
/opt/docker-scripts/<app>
. A certain branch can be specified
as well. When a branch is given, then it is saved to
/opt/docker-scripts/<app>-<branch>
.
init <app> [@<container>]
Initialize a container directory by getting the file settings.sh
from the given app directory.
The argument app can be a subdirectory of
/opt/docker-scripts/
, or any other directory, absolute or
relative, that can be reached from the container's directory.
If the second argument is missing, the current directory will be
used for initializing the container. If container starts with
'./' it will be relative to the current directory. If container
starts with '/', it will be an absolute path. Otherwise, it will
be done on /var/ds/<container>
.
info
Show some info about the container of the current directory.
build
, create
, config
Build the image, create the container, and configure the guest system inside the container.
runcfg [<cfg>]
Run a configuration script inside the container.
start
, stop
, restart
Start, stop and restart the container.
shell
Get a shell on the container.
exec
Execute a command from outside the container.
snapshot
Make a snapshot of the container.
remove
Remove the container and the image.
runtest [-d|--debug] [<test-script.t.sh>...]
Run the given test scripts. If no test-script is given all the
test scripts in the working directory will be run. Test scripts
have the extension .t.sh
test [-d|--debug] [<test-script.t.sh>...]
Run the given test scripts inside the ds-test container. It
actually call the command runtest
inside the container with the
same options and arguments.
help
Display a help message.
~/.ds/
The default ds config directory.
~/.ds/config.sh
The configuration file.
~/.ds/ds.sh
Optional customization file.
./settings.sh
It is located in directory of the container and keeps the
settings of the container and the settings of the
application installed inside it.
DSDIR
Overrides the default ds config directory (~/.ds/).
The functions of DockerScripts can be redifined or customized without having to touch the code of the installed script. The framework does this by including optional customization scripts, if it finds them. These scripts are included (sourced) in this order:
$DSDIR/ds.sh
(by default ~/.ds/ds.sh
)$APPS/<app>/ds.sh
(by default /opt/docker-scripts/<app>/ds.sh
)$CONTAINERS/<container>/ds.sh
(by default /var/ds/<container>/ds.sh
)A newly defined function will override a previously defined one. To
reuse the previous function inside the new one (if this makes sense),
we can rename it before the new function is defined, like this:
rename_function fun1 orig_fun1
.
Also, new commands can be defined for each application and for each
container. The framework will look for a custom command named
cmd_command
in these places:
$APPS/<app>/cmd/command.sh
(by default /opt/docker-scripts/<app>/cmd/command.sh
)$DSDIR/cmd/command.sh
(by default ~/.ds/cmd/command.sh
)$CONTAINERS/<container>/cmd/command.sh
(by default /var/ds/<container>/cmd/command.sh
)These files will be included (sourced) if they exist. If the name of a
newly defined command is the same as an existing command, it will
override the existing one. To reuse the previous command definition
inside the definition of new one (if this makes sense), we can rename
it before the new function is defined, like this:
rename_function cmd_command1 orig_cmd_command1
.
git clone https://gitlab.com/docker-scripts/ds /opt/docker-scripts/ds
cd /opt/docker-scripts/ds/
make install
ds
ds -h
ds pull wsproxy
ds init wsproxy @wsproxy
source ds cd @wsproxy # (or: cd /var/ds/wsproxy/)
vim settings.sh
ds build
ds create
ds config
ds pull moodle
ds init moodle @moodle1
source ds cd @moodle1 # (or: cd /var/ds/moodle1/)
vim settings.sh
ds build
ds create
ds config
ds wsproxy add
ds wsproxy ssl-cert -t
ds wsproxy ssl-cert
ds pull shellinabox
ds init shellinabox @shell1
source ds cd @shell1
vim settings.sh
ds build
ds create
ds config
ds @wsproxy domains-add shell1-example-org shell1.example.org
ds @wsproxy get-ssl-cert user@example.org shell1.example.org --test
ds @wsproxy get-ssl-cert user@example.org shell1.example.org
ds pull schooltool
ds init schooltool @school1
source ds cd @school1
vim settings.sh
ds build
ds create
ds config
source ds cd @wsproxy
ds domains-add school1-example-org school1.example.org
ds get-ssl-cert user@example.org school1.example.org --test
ds get-ssl-cert user@example.org school1.example.org
Copyright (C) 2017 Dashamir Hoxha (dashohoxha@gmail.com). The code is on GitLab at https://gitlab.com/docker-scripts/ds.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.