简体   繁体   中英

How can I verify if a file exist inside container docker?

I can copy it with this code:

exec('docker cp selenium:"/home/seluser/Downloads/'.$fileName.'" '.$filePath.'.pdf');

but I need verify before if it exist

You could use: exec(ls <your file> > /dev/null 2>&1 && echo 0 || echo 1) which will output 1 if the file <your file> does not exist check the output or replace echo 0 with the command to execute in case the file exist

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM