Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all directories and files inside docker container?

Following is my dockerfile:

FROM python:3.6.5-windowsservercore
COPY . /app
WORKDIR /app
RUN pip download -r requirements.txt -d packages

To get list of files in the image, I have tried both the following options, but there is error:

encountered an error during CreateProcess: failure in a Windows system call: 
The system cannot find the file specified. (0x2) extra info: 
{"CommandLine":"dir","WorkingDirectory":"C:\\app"......
  1. Run docker run -it <container_id> dir
  2. Modify the dockerfile and add CMD at end of dockerfile - CMD ["dir"], then run docker run <container_id> dir

How to list all directories and files inside docker?

like image 746
variable Avatar asked Feb 03 '26 20:02

variable


1 Answers

This is what I found helpful in the end. Thanks to Nischay for leading the way. The great thing about this, of course, is that one may examine the files even if the publish fails at a later stage.

# Copy everything...
COPY . ./
# See everything (in a linux container)...
RUN dir -s    
# OR See everything (in a windows container)...
RUN dir /s
like image 56
Dave Avatar answered Feb 06 '26 13:02

Dave



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!