Store Docker image files on external drive in macOS - macos

I'm using a Mac Book Pro with 128Gb disk. Is there any way to have the Docker images be stored on an external hard drive rather than on the Mac's main drive?
I don't have that much free space, and can't afford to remove any installed software. Ideally I'd like to have Docker fetch the images from an external drive. Can this be done using a symlink?

Eventually figured out that docker can use a symlink. In a macOS setup the file that I want to place in an external drive is located at:
~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/
and is named
Docker.qcow2
Just move the file to an external disk drive (for instance) and create a symlink pointing to the new location.

Please create a symlink to your desired external drive location:
create a symlink from ~/Library/Containers/com.docker.docker to your external drive location
EHOME=/Volumes/<your-external-drive-name>
ln -s $EHOME/Library/Containers/com.docker.docker ~/Library/Containers/com.docker.docker

I was able to get this working and documented it here:
This tutorial will explain how to setup an external disk to store docker images and containers.
https://github.com/09wattry/run-docker-external-storage
It is basically a symlink to the folders mentioned.

Related

UNIX executable file downloaded from internet not set as executable automatically in Mac

I have a UNIX executable file which could be executed by just clicking it. I uploaded it to a cloud service, and then downloaded it on another Mac computer. Now this Mac doesn't recognise it as an executable file anymore. So I have to use the chmod +x command. Is there any way to keep the executable nature of the file intact, upon upload and download from the internet?
I could use the chmod +x command to make the downloaded file executable. But it was originally executable. I don't understand why this mode is changed upon upload and download from the internet.
Different cloud services will have different behavior with respect to preserving the Unix file modes and ACLs. When uploaded to a cloud service, the files may be stored on a different type of filesystem or may not be stored as files at all.
On my mac I copied a file to iCloud Drive and the executable mode was preserved. Microsoft OneDrive also preserved the executable mode. Both iCloud Drive and OneDrive integrate with Finder.
You may consider using tar or gzip to create an archive file containing your executable. The archive format will preserve the file modes and the archive file can be stored on any cloud service.

In which directory should I install Google Cloud's SDK (and SDKs in general)

Currently / For Some Reason, Google Cloud's SDK folder is located directly in my home /Users/myname directory. I like to keep my home directory clean of any files + folders outside the main couple of core directories: Applications, Documents, Downloads, Dropbox, etc. An SDK seems like something that should be installed in the macbook's initial /Library directory, not somewhere in Users/myname, and I'd like to move this folder to where it belongs.
As a follow up question - how should I go about this? Should I simply drag and drop the folder into a new location, or uninstall and reinstall entirely? Also, other than updating my .bash_profile, is there anything else to be done when moving the SDK location so that it still works?
Thanks!
The google-cloud-sdk directory is in your HOME because that's where you extracted it :)
From the quickstart instructions:
Extract the archive to any location on your file system; preferably, your home directory.
So your home directory is the recommended location, but you can put it wherever you'd like. If you run the install.sh script the SDK will be configured in your shell pointing to that location.
If you don't want it taking up space in your home directory you could try /usr/local/lib, which is a typical location for "libraries".

How to access files downloaded on my windows machine from boot2docker?

I have a file which is downloaded from browser. I have boot2docker on my windows machine. From boot2docker, how can i access my downloaded file? Is it possible?
If you setup shared directories with VirtualBox, it is possible, however, it is overly complex for not much.
I'd advise to simply use curl or wget within boot2docker to download your file(s).
An other solution would be to use winscp to upload your file from windows to boot2docker.
The download folder should be mounted in boot2docker already.
From Boot2Docker's README:
Alternatively, Boot2Docker includes the VirtualBox Guest Additions
built in for the express purpose of using VirtualBox folder sharing.
The first of the following share names that exists (if any) will be
automatically mounted at the location specified:
Users share at /Users
/Users share at /Users
c/Users share at /c/Users
/c/Users share at/c/Users`
c:/Users share at/c/Users`
Since Windows' default download location is C:\Users\[username]\Downloads your downloaded file should be in the Boot2Docker VM at /c/Users/[username]/Downloads.

Access a saved ipython notebook on an external drive (mac)

I'm trying to access an ipython notebook that was saved to an external HD. Is this possible?
Specifically, I saved an ipython notebook to a dropbox folder (locally synced) on one computer. I am now trying to open that ipython notebook on another computer that syncs to the same dropbox account -- only computer b's dropbox folder is on an external HD.
This seems so basic, but I've looked everywhere for an answer on this and am afraid I'm missing something more fundamental here.
Create a symbolic link to your external drive; store this link somewhere on the main drive.
For example, my Dropbox folder is on an external flash card, so I used a terminal session to do the following:
$ ln -s /Volumes/SDCARD/Dropbox ~/Documents/DB
(Screenshots here)
From terminal, if you have Anaconda installed, type:
jupyter notebook --notebook-dir=/Volumes/NameofExternalDrive

How to build a dmg Mac OS X file (on a non-Mac platform)?

Is it possible to build a .dmg file (for distributing apps) from a non-Mac platform?
And if yes, how?
Yep, mkfs.hfsplus does it.
dd if=/dev/zero of=/tmp/foo.dmg bs=1M count=64
mkfs.hfsplus -v ThisIsFoo /tmp/foo.dmg
This creates a dmg file (in this case 64M) that can be mounted on a mac. It can also be mounted on linux, with something like
mount -o loop /tmp/foo.dmg /mnt/foo
after wich you just copy the content you want to it (in /mnt/foo). Unmount it, and the dmg can be copied over to a mac and mounted there.
A project I work on creates DMG files on Linux using genisoimage:
mkdir -p dmgdir/progname.app/Contents/{MacOS,Resources}
...copy your PkgInfo, Info.plist to Contents...
...copy your .icns to Resources...
...copy your other things to where you expect them to go...
genisoimage -V progname -D -R -apple -no-pad -o progname.dmg dmgdir
If you want to be really fancy, you can steal the .DS_Store file from a DMG made on a Mac with a volume name progname and app bundle called progname.app (i.e., matching what you want to create off the Mac) where you've put a background in .background/background.png and a symbolic link to /Applications in the root dir, and put that in dmgdir along with your own a symbolic link to /Applications.
Finally, if you want to create a compressed DMG, get the dmg tool from libdmg-hfsplus:
dmg uncompressed.dmg compressed.dmg
git clone https://github.com/hamstergene/libdmg-hfsplus
cd libdmg-hfsplus && cmake . && make && cd dmg
./dmg --help
Makefile:
dmg:
genisoimage -D -V "$(PROJECT) $(VERSION)" -no-pad -r -apple -o project-$(VERSION)-uncompressed.dmg $(DARWIN_DIR)
./dmg dmg project-$(VERSION)-uncompressed.dmg project-$(VERSION).dmg
uncompressed works out of the box, compression may cause problems - the origin/master at least produces a 'checksum' error on snow-leopard
It does seem possible to create DMG files with some third party tools. A quick google search reveals at least a few commercial tools:
TransMac
MagicISO
Not sure about any OSS/freeware options, but it does at least seem possible if you are so inclined.
Edit: I also forgot about MacDrive, which is another great tool for working with HFS+ filesystems under windows. Since a DMG is basically just a HFS+ filesystem snapshot, it is probably possible with MacDrive to create DMG's as well.
I'm not sure if anyone is still watching this thread, but I tried TransMac as recommended by Nik Reiman.
Using this tool I was able to, running on Windows 7, create dmg files which were mountable on OSX 10.8.3.
Downside
The only downside for us is that this tool doesn't appear to be command-line friendly; for us that's a deal-breaker as we need to be able to have an automated tool which our build server (Windows based) can use to build dmg files on-the-fly.
See mkfs.hfsplus
If you're distributing Mac apps, then surely you have a Mac to write and test them. Why not simply use that same Mac to create the disk image?
[Edit] Alternatively, if you're distributing a portable app, for example a Java .jar file, why bother with a disk image? Macs understand .zip and .tar.gz archives just fine.
I guess what I'm getting at is, I don't understand how one might need a DMG disk image, but not have a Mac with which to create it.

Resources