简体   繁体   中英

Check contents of folder in Docker container

I'm trying to find out if /opt/refresh_key.sh exists in my docker container. I've tried the likes of docker container inspect container_name and also docker run -it image_name sh but neither seem to be what I need.

Docker run launch a new container. If you want to dive inside your existing container you should do:

docker exec -it <container-name> /bin/bash

and then you will have access to the filesystem of the existing container.

You can find container-name by doing docker ps .

Try the following :

docker exec -it <contailer-id> [[ -f "/bin/sh" ]] && echo "exists"

Place your file name in place of /bin/sh

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