Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker exec rm not working

Tags:

docker

I want to remove a file in my docker through docker exec:

user@mongo:~$ docker exec 765511b2869e rm -rf /backup/*.zip
user@mongo:~$ docker exec 765511b2869e ls /backup
-rw-r--r-- 1 root root 40103038 Mar 13 15:26 backup-20170313.zip

Apparently it is not working.

What could be wrong?

like image 613
Augustin Riedinger Avatar asked Mar 13 '17 15:03

Augustin Riedinger


People also ask

What is rm command in docker?

Force-remove a running container This command force-removes a running container. $ docker rm --force redis redis. The main process inside the container referenced under the link redis will receive SIGKILL , then the container will be removed.

What does the -- rm option do when used with the docker Run command?

The docker run command is docker's standard tool to help you start and run your containers. The --rm flag is there to tell the Docker Daemon to clean up the container and remove the file system after the container exits.


1 Answers

This is expected behavior. Characters like * are interpreted by the shell. Thus you need to invoke a shell for them to work.

docker exec 765511b2869e sh -c 'rm -rf /backup/*.zip'
like image 124
mtt2p Avatar answered Oct 13 '22 20:10

mtt2p