summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <Colomar.6.4.3@GMail.com>2020-03-29 00:08:26 +0100
committerGitHub <noreply@github.com>2020-03-29 00:08:26 +0100
commit5e962ff6b9b04607c78e969e74b2031c0242a3cd (patch)
tree9515b936c0e4bfbdb40f392679e7a098c1868acf
parenta81f498cf58e73d6db8c577a4f50f8d4e7a100fa (diff)
parentbd611f1397767e15b277419ab441a56213c80c69 (diff)
Merge pull request #26 from alejandro-colomar/master
Improve docker command
-rw-r--r--README.rst14
-rwxr-xr-xlaundry-symbol-reader-dk21
2 files changed, 12 insertions, 23 deletions
diff --git a/README.rst b/README.rst
index a6e2fb7..6c328c4 100644
--- a/README.rst
+++ b/README.rst
@@ -113,18 +113,18 @@ There are two options: you can run the docker command directly, or you can
run a script included in this repository (you need to download the script (or
the full repository) for the second option).
-Both variants require that the image used is in a subdirectory contained by the
-`$PWD`. The reason is that docker will mount the `$PWD` inside the container
-to have access to the image. It can be modified by modifying the line that
-runs docker.
-
docker:
.......
.. code-block:: sh
- $ docker container run --tty --interactive --volume $PWD:$PWD \
- --env IMG_FNAME=$PWD/path/to/image laundrysymbolreader/reader
+ $ path=path/to/image
+ $ dir=$(realpath $(dirname ${path}))
+ $ fname=$(basename ${path})
+ $ docker container run --tty --interactive \
+ --volume ${dir}:${dir} \
+ --env IMG_FNAME=${dir}/${fname} \
+ laundrysymbolreader/reader
script:
.......
diff --git a/laundry-symbol-reader-dk b/laundry-symbol-reader-dk
index 37b6da7..1cc1649 100755
--- a/laundry-symbol-reader-dk
+++ b/laundry-symbol-reader-dk
@@ -12,30 +12,19 @@
################################################################################
# functions #
################################################################################
-wrap_env()
-{
- env="--env IMG_FNAME=${PWD}/$1"
-}
-wrap_vol()
-{
- vol="--volume ${PWD}:${PWD}"
-}
-
-wrap_options()
-{
- opt="--tty --interactive $1 $2"
-}
################################################################################
# main #
################################################################################
main()
{
+ dir=$(realpath $(dirname "$1"))
+ fname=$(basename "$1")
- wrap_vol
- wrap_env "$1"
- wrap_options "${vol}" "${env}"
+ vol="--volume ${dir}:${dir}"
+ env="--env IMG_FNAME=${dir}/${fname}"
+ opt="--tty --interactive ${vol} ${env}"
cmd="docker container run ${opt} laundrysymbolreader/reader"
${cmd}