Uninstall Docker

RahulR
New Contributor II

Hi All, 

We are working on removing Docker desktop from Macs, tried few scripts for uninstalling through Jamf Pro however we are getting an error stating root access is needed. Wanted to check if anybody knows of a way to remove docker through jamf.
The script user

#!/bin/bash
 
# Uninstall Script
 
if [ "${USER}" != "root" ]; then
echo "$0 must be run as root!"
exit 2
fi
 
while true; do
  read -p "Remove all Docker Machine VMs? (Y/N): " yn
  case $yn in
    [Yy]* ) docker-machine rm -f $(docker-machine ls -q); break;;
    [Nn]* ) break;;
    * ) echo "Please answer yes or no."; exit 1;;
  esac
done
 
echo "Removing Applications..."
rm -rf /Applications/Docker.app
 
echo "Removing docker binaries..."
rm -f /usr/local/bin/docker
rm -f /usr/local/bin/docker-machine
rm -r /usr/local/bin/docker-machine-driver*
rm -f /usr/local/bin/docker-compose
 
echo "Removing boot2docker.iso"
rm -rf /usr/local/share/boot2docker
 
echo "Forget packages"
pkgutil --forget io.docker.pkg.docker
pkgutil --forget io.docker.pkg.dockercompose
pkgutil --forget io.docker.pkg.dockermachine
pkgutil --forget io.boot2dockeriso.pkg.boot2dockeriso
 
echo "All Done!"
1 ACCEPTED SOLUTION

karthikeyan_mac
Valued Contributor

Hi @RahulR Jamf Pro runs the scripts as root so you do not need the first part of the script. You also waiting for user input in while loop which will not work with Jamf. Check with the below script. I removed both the parts from your scripts.

Thanks.

 

 

#!/bin/bash
# Uninstall Script

while true; do
	docker-machine rm -f $(docker-machine ls -q); break;
	
done

echo "Removing Applications..."
rm -rf /Applications/Docker.app

echo "Removing docker binaries..."
rm -f /usr/local/bin/docker
rm -f /usr/local/bin/docker-machine
rm -r /usr/local/bin/docker-machine-driver*
rm -f /usr/local/bin/docker-compose

echo "Removing boot2docker.iso"
rm -rf /usr/local/share/boot2docker

echo "Forget packages"
pkgutil --forget io.docker.pkg.docker
pkgutil --forget io.docker.pkg.dockercompose
pkgutil --forget io.docker.pkg.dockermachine
pkgutil --forget io.boot2dockeriso.pkg.boot2dockeriso

echo "All Done!"

 

  

View solution in original post

4 REPLIES 4

karthikeyan_mac
Valued Contributor

Hi @RahulR Jamf Pro runs the scripts as root so you do not need the first part of the script. You also waiting for user input in while loop which will not work with Jamf. Check with the below script. I removed both the parts from your scripts.

Thanks.

 

 

#!/bin/bash
# Uninstall Script

while true; do
	docker-machine rm -f $(docker-machine ls -q); break;
	
done

echo "Removing Applications..."
rm -rf /Applications/Docker.app

echo "Removing docker binaries..."
rm -f /usr/local/bin/docker
rm -f /usr/local/bin/docker-machine
rm -r /usr/local/bin/docker-machine-driver*
rm -f /usr/local/bin/docker-compose

echo "Removing boot2docker.iso"
rm -rf /usr/local/share/boot2docker

echo "Forget packages"
pkgutil --forget io.docker.pkg.docker
pkgutil --forget io.docker.pkg.dockercompose
pkgutil --forget io.docker.pkg.dockermachine
pkgutil --forget io.boot2dockeriso.pkg.boot2dockeriso

echo "All Done!"

 

  

Hi Karthikeyan,

Thank you so much for the help, it worked. Thanks a lot.

 

 

AlexHoffman
New Contributor III

Just want to point out something that tripped me up when I had to remove docker from my fleet. Make sure to run an update inventory on devices so that Jamf knows the app has been deleted. Also if devices continue to appear as though they have docker installed but user says they deleted, verify it's not sitting in the recycle bin and that there are no rogue launchAgents or lauchDaemons or Preference files lingering. 

RahulR
New Contributor II

Git it, will check on it before pushing the scripts