Home > database >  How can I check if a folder exists in a docker?
How can I check if a folder exists in a docker?

Time:01-11

I want to check if a folder exists in a docker then in a bash script act according to the answer:

toto = docker exec -it symfony sh -c " test -d imports && echo '1' "
if [[ "$toto" == '1' ]]; then
echo "il exists"
fi

CodePudding user response:

Just run the command inside docker container.

if docker exec symfony test -d imports; then
    echo "il exists"
fi
if docker exec symfony [ -d imports ]; then
    echo "il exists"
fi

Your code has many problems. Check your script with shellcheck. Consider reading: How do I set a variable to the output of a command in Bash?

  • Related