diff options
author | Alejandro Colomar <Colomar.6.4.3@GMail.com> | 2020-03-29 00:08:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-29 00:08:26 +0100 |
commit | 5e962ff6b9b04607c78e969e74b2031c0242a3cd (patch) | |
tree | 9515b936c0e4bfbdb40f392679e7a098c1868acf | |
parent | a81f498cf58e73d6db8c577a4f50f8d4e7a100fa (diff) | |
parent | bd611f1397767e15b277419ab441a56213c80c69 (diff) |
Merge pull request #26 from alejandro-colomar/master
Improve docker command
-rw-r--r-- | README.rst | 14 | ||||
-rwxr-xr-x | laundry-symbol-reader-dk | 21 |
2 files changed, 12 insertions, 23 deletions
@@ -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} |