2

I'm trying to write a hardening script to remove the cron directory in an alpine Linux based docker image.

docker run -it alpine:3.7
rm -rf /var/spool/cron
rm: can't remove '/var/spool/cron': Invalid argument

Sometimes the cron directory appears to have a crontabs file in it sometimes not, and removing it makes no difference to being able to delete the folder.

The odd part is that this is on an Amazon Linux 2 Image, if I try from my Windows development box or an Ubuntu AMI the directory is able to be removed without issue.

Whats going on here?

Dave M
  • 4,514
  • 22
  • 31
  • 30
Daniel Powell
  • 76
  • 2
  • 14
  • Did you check dmesg? Maybe it says more. – Peter Feb 25 '19 at 11:25
  • I just checked it on a fresh new Amazon Linux 2 t2.micro instance and the deletion works for me. Can you please verify that it happens in other servers than the one you tried? – Itai Ganot Feb 25 '19 at 16:56
  • I was unable to reproduce this on a fresh Amazon Linux 2 instance. You say it sometimes has crontabs and sometimes not? That doesn't match with your example. It would be a clean image each time and would not change. Are you using any --volume arguments? What else can you tell us about the host system? Any special configuration? Did you configure a different storage driver for Docker? An `Invalid argument` error is usually due to the underlying filesystem not implementing something. – Jeff Snider Feb 25 '19 at 16:58
  • This occured on both a Windows 7 enterprise machine running docker 18.06.1-ce-win73 and on the current latest AL2 image, nothing was customised in either install and no extra volumes were mounted. – Daniel Powell Feb 26 '19 at 06:17
  • You need to mount it - https://docs.docker.com/docker-for-windows/ - see the item about shared drive for linux containers. – Schrute Feb 26 '19 at 17:14
  • @Schrute this happened on a linux only EC2 instance as well – Daniel Powell Mar 01 '19 at 03:06
  • 1
    Can you edit your question and add the steps you go through on AWS to recreate this? What region? Instance type? Commands run over ssh? A full copy of the terminal output for instance would be helpful. I don't think you're going to get an answer without providing more details. – Jeff Snider Mar 01 '19 at 15:55

0 Answers0