Use silent docker commands for cleaner scripting
This commit is contained in:
parent
851f4cb7f3
commit
9a3281ff56
5
d
5
d
@ -6,7 +6,7 @@ buildroot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
|
||||
|
||||
# Check if the docker image exists
|
||||
# If not, ask if it should be built
|
||||
if ! docker image ls -f reference=${imagename} | grep ${imagename} >/dev/null; then
|
||||
if [[ ! $(docker image ls -q -f reference=${imagename}) ]]; then
|
||||
echo "Docker image does not exist."
|
||||
echo "Do you wish to build it? (This could take a while)"
|
||||
read -r -p "[y/N]: " response
|
||||
@ -23,7 +23,8 @@ fi
|
||||
|
||||
# Check if a container is already running the image
|
||||
# If so, execute the command in the running container
|
||||
if docker ps -f name=${imagename}-run | grep ${imagename}-run ; then
|
||||
#if docker ps -f name=${imagename}-run | grep ${imagename}-run ; then
|
||||
if [[ $(docker ps -q -f name=${imagename}-run) ]]; then
|
||||
docker exec -it ${imagename}-run "$@"
|
||||
else
|
||||
docker run -it --rm -v ${buildroot}:/opt --name ${imagename}-run ${imagename} "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user