Ok, today I'm attempting the venerable "Hello World" in Docker for Mac, having only skimmed the instructions...
- Download the Docker installer, click it, drag the whale icon thing to the Applications folder icon thing. (You'll probably have to create a Docker ID to download it - keep it. You'll use it a lot later.)
- Open the Applications folder in Finder, click the Docker app. Panic during the brief interlude with the spinning beach ball of death. A Tiny Whale icon appears in the notification area. You are prompted to enter/create your Docker ID. Probably.
- Look at Tiny Whale. Wonder what the hell you do next....
[OVERSIMPLIFICATION WARNING] Docker makes software portable. You see people comparing Docker images to CDs and game cartridges, etc, but it's more than that. It's like a CD you can play in your tape deck or your SNES or your record player or your lawnmower... as long as that lawnmower runs Docker. People will want tell you things about virtualisation and shared kernels and file systems and stuff, but right now we don't care. Right now Docker is magic.
Docker software comes as an "image" (which contains the software, libraries, settings, etc). Docker allows you to run that image on anything with Docker installed. The running instance of the image is a called a "container".
At the moment, there are no images on my Mac. How can I tell? First, I fire up a Terminal because apparently it's still 1978. (Make sure you set it to with black with green text for the full effect.)
$ docker info
Boring. So I need to get an image I can run. Luckily, whatever the default Docker repository is (Docker Hub? Probably.) has a "Hello World" image for just such an occasion. It's called "hello-world".
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
This is vaguely reassuring, if not terribly impressive. It downloaded an image, spun it up into a container and ran the executable inside. You can run the "ambitious" option* it suggests ("docker run -it ubuntu bash") and this will download and spin up the Ubuntu bash shell. Which gives you a different prompt to play with.
So far so good, but this is all far too command line-y for my tastes. Tiny Whale's dropdown (on the Mac version at least) has a link for Kitematic, which seems to be a fairly nifty GUI. Trying that next...
Why are we doing this? See Part 1.
* Bonus reading: Literally the fourth docker container I ever ran was Docker DOOM, which (with a bit of legwork) let me shoot the third container to death with a shotgun.
Posted Saturday, July 7, 2018.