Skip to content

Docker Exec Path-based Commands

November 17th, 2017 - ITTutorial(1 min)

TL;DR: Use sh -c "command with arguments"

I’ve tried to execute

docker exec <container> du /

in order to see the size used by a container’s logs. Unfortunately, this resulted in an error along the lines:

du: C:/Program Files/Git: No such file or directory

This means that my git bash prompt interpreted the / itself. In order to get around this limitation, you need to run:

docker exec <container> sh -c 'du -h /'

HTH,

Share on
Reddit
Linked in
Whatsapp

A little experiment: