Can the “drag to applications” of a mounted DMG volume be done in the terminal

dmgmountterminal

Attempting to automatically install a .DMG downloaded(of Docker), so that the host has access to docker run etc. in Terminal.

I can attach the volume with no issue with:

curl -O https://download.docker.com/mac/stable/Docker.dmg > ./Docker.dmg

And then mount it:

hdiutil attach Docker.dmg

How do I step further from here and actually mock the "drag and drop to Applications" that will then be prompted to the user?

To my knowledge there is no .pkg inside this image. So I can't use the related question's answers(that were dubded as duplicate before, this question is more precise.)

Best Answer

Use this command once the .dmg is open to copy the app:

 cp -R /Volumes/Docker/Docker.app /Applications

The user will get the usual pop-up security window when the app is first run:

enter image description here

You can further automate the process by ejecting the disk image:

 diskutil unmount /Volumes/Docker

Then opening the app to get the security warning:

 open /Applications/Docker.app