0

If I do

$ sudo docker cp c7033ac0fdd2:/home/mydir/myfile.txt .

file is copied. But if I do

$ sudo docker ls c7033ac0fdd2:/home/mydir/
docker: 'ls' is not a docker command.
See 'docker --help'

How to list directory content then and why it doesn't made with with ls?

2

Assuming a couple of reasonable things (there is a shell and an ls program and the entrypoint for the container is not super tightly locked down)

docker exec c7033ac0fdd2 ls /home/mydir

As to "why?", there is a limit on how much ought to be built into docker and how much you should do with external programs.

If the assumptions are not valid, then you can export the contents of the container as a tar file and look at that, e.g.

docker container export c7033ac0fdd2 | tar vtf - | grep /home/mydir

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.