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.)

1 Answer 1


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
  • I'll give this a go and test it on a fresh OSX with no Docker. Will be interesting to see if it works :P I've been using hdiutil to mount and unmount, should one use diskutilinstead?
    – cbll
    Sep 7, 2017 at 13:27
  • hdiutil will work just as well as diskutil, I think.
    – IconDaemon
    Sep 7, 2017 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .