Relates to this GitHub issue (now closed).
Opening a thread here at the suggestion of kobelb, who closed the original GitHub issue. I can confirm, though, that the problem is present as of the latest available Kibana Docker image.
Copying my comment from that thread here:
Running into this same issue with docker.elastic.co/kibana/kibana:5.6.1.
[user@server]$ docker run --user root -ti --rm docker.elastic.co/kibana/kibana:5.6.1 bash
[root@70ac29ce9a7e kibana]# bin/kibana-plugin remove x-pack
Removing x-pack...
Unable to remove plugin because of error: "ENOTEMPTY: directory not empty, rmdir '/usr/share/kibana/plugins/x-pack/.phantom'"
[root@70ac29ce9a7e kibana]# rm -rf /usr/share/kibana/plugins/x-pack/.phantom
rm: cannot remove '/usr/share/kibana/plugins/x-pack/.phantom': Directory not empty
[root@70ac29ce9a7e kibana]# ls /usr/share/kibana/plugins/x-pack/.phantom -l
ls: cannot access /usr/share/kibana/plugins/x-pack/.phantom/phantomjs-2.1.1-linux-i686.tar.bz2: No such file or directory
ls: cannot access /usr/share/kibana/plugins/x-pack/.phantom/phantomjs-2.1.1-linux-x86_64.tar.bz2: No such file or directory
ls: cannot access /usr/share/kibana/plugins/x-pack/.phantom/phantomjs-2.1.1-macosx.zip: No such file or directory
ls: cannot access /usr/share/kibana/plugins/x-pack/.phantom/phantomjs-2.1.1-windows.zip: No such file or directory
total 0
?????????? ? ? ? ? ? phantomjs-2.1.1-linux-i686.tar.bz2
?????????? ? ? ? ? ? phantomjs-2.1.1-linux-x86_64.tar.bz2
?????????? ? ? ? ? ? phantomjs-2.1.1-macosx.zip
?????????? ? ? ? ? ? phantomjs-2.1.1-windows.zip
[root@70ac29ce9a7e kibana]# rm -f /usr/share/kibana/plugins/x-pack/.phantom/*
[root@70ac29ce9a7e kibana]# ls /usr/share/kibana/plugins/x-pack/.phantom -l
ls: cannot access /usr/share/kibana/plugins/x-pack/.phantom/phantomjs-2.1.1-linux-i686.tar.bz2: No such file or directory
ls: cannot access /usr/share/kibana/plugins/x-pack/.phantom/phantomjs-2.1.1-linux-x86_64.tar.bz2: No such file or directory
ls: cannot access /usr/share/kibana/plugins/x-pack/.phantom/phantomjs-2.1.1-macosx.zip: No such file or directory
ls: cannot access /usr/share/kibana/plugins/x-pack/.phantom/phantomjs-2.1.1-windows.zip: No such file or directory
total 0
?????????? ? ? ? ? ? phantomjs-2.1.1-linux-i686.tar.bz2
?????????? ? ? ? ? ? phantomjs-2.1.1-linux-x86_64.tar.bz2
?????????? ? ? ? ? ? phantomjs-2.1.1-macosx.zip
?????????? ? ? ? ? ? phantomjs-2.1.1-windows.zip
No amount of trying will let me remove these files, so the uninstall command for x-pack (bin/kibana-plugin remove x-pack
) appears to be straight up broken in the latest official Kibana docker image.