Containers Rock! Why I’m A Docker Fan

Docker for the Macintosh has recently emerged from beta and I’m ecstatic.

Docker implements a way of walling off a piece of software from the underlying operating system using a tech they call “containers”.

This is an absolute godsend for deploying services. One of the problems in system administration is the cost and complexity of spinning up a new service and then removing it from a computer once it is no longer required.

Software when it is installed and run can spray pieces of itself all over the computer’s file system and getting it out again is difficult.

Previously we have used virtual machines to isolate this problem. That has it’s own costs, a virtual machine means you are running (at least) two complete operating systems on the hardware. It also has a cost in memory and hard disk space.

Containers lower the cost considerably. They have all the advantages of virtual machines but share the operating system kernel with each other and the underlying OS. This makes them smaller and consuming considerably less resources than virtual machines. This also makes them quicker to download and deploy.

Since Docker is open source it means that there is now a huge community around it. Docker containers are easily available for a huge range of applications, a quick visit to Dockerhub will show you how large.

Docker containers may well be the holy grail of app deployment. They certainly tick all the boxes system administrators require.

Using Docker

So how easy is it to use? Installing it is trivial, just download the install package and copy the Docker application to your Applications folder. You might also want to download
Kitematic which provides a GUI interface to Docker, it also just requires downloading and copying the app to your Applications folder. It is just as easily installed on a Linux box.

You can also install bash completion for docker with this

curl -XGET https://raw.githubusercontent.com/docker/docker/master/contrib/completion/bash/docker > brew --prefix/etc/bash_completion.d/docker

I wish I could tell you how easy it is to build a Docker container from scratch but every time I searched DockerHub for a container I wanted someone else had already built it, or built a large chunk of it.

As an example, I wanted a container running Python 3, Jupyter and the add-on for bash notebooks. Sure, I could have built it from scratch but Continuum, the Anaconda people, already have a Docker container with Python 3 and Jupyter (along with a bunch of other useful Python libraries) installed so :-

docker run -it continuumio/anaconda3 /bin/bash

which will download and run the Python 3 version of Anaconda in a container. Then when the container runs (the -it makes it an interactive container) :-

pip install bash_kernel
python -m bash_kernel.install

then exit the container and at the terminal prompt

docker ps -a
docker commit <container_name> tonyw/jupyter

The ps -a lists all the containers so I know which one to commit and the commit saves the changed container with (optionally) a new name. Now we can run the new container.

docker -d -p 8888:8888 -v /Users:/Users -rm tonyw/jupyter 
 jupyter notebook --ip='*' --port=8888 
 --notebook-dir /Users/tonyw/dev/Notebooks 
 --no-browser

This runs the Docker container in ‘daemon’ mode and when the container starts runs the command at the end, in this case Jupyter in notebook mode.

Of course if I just want to run Python 3.5 instead of Jupyter I can always replace the -d with -it and the jupyter command with bash and I get a shell in the container.

Docker Magic

Now all the Docker gurus out there are screaming at me that I should use a Dockerfile to build my custom container and define all sorts of magical stuff like the default command to run when the container starts and the working directory and all the rest so I didn’t need them all in my long command line. Frankly, while that would probably be a good idea I haven’t quite managed to learn how to do all that automated magic and it almost seems like too much work.

Perhaps for my next blog post.

Further Reading

Macadmins Dockerhub
Pepijn Bruienne’s talk on Docker from PSU MacAdmins 2015

Happy Birthday To My Favourite OS

I thought the 15th birthday of my favourite operating system was the perfect time to look at why I love it so.

I do love OS X, I certainly think it is the pinnacle of operating systems. Don’t get me wrong, I know it has faults and I am more than happy to enumerate them given the chance. It is, however, the best available operating system at the moment, it has been for many years.

Alan Kay, the scientist who worked at Xerox PARC on the first GUI, called the Macintosh “the first computer worth criticising”. I’ve always thought of OS X as “the first OS worth criticising”. In case you’re wondering why Alan Kay, he’s one of my gods. Go read his Wikipedia page. Continue reading

Why Alex Is Wrong And What Are Apple’s real Software Problems

OK, that headline is a bit inflammatory and an insult to a perfectly good tech journalist but Alex Kidman here is the latest in a long line of commentators to take a swipe at Apple for the quality of its software. Unfortunately he grabs the wrong end of the clue stick.

I am not going to argue that there aren’t some things that Apple could do to improve software quality, indeed I will point out some of them before I conclude. What I would like to do is look at some of the reasons there are problems. I will also point out some of the things that won’t fix the problems and why. As I do I’ll show why Alex is partly wrong though partly correct at the core of his arguments.

First, software is hard. I started out my professional life as a programmer, mostly writing code for accounting software, most of the time in C. It is impossible for anyone who has not spent several years writing software to understand the complexity of what you do and the difficulties you find in proving it’s correct. Continue reading

Looking for work

Do you have a Macintosh fleet of 20 or more or a company full of iPhones and need some assistance? Then talk to me, I’m currently looking for work, either permanent or contract, in the Sydney area.

Who am I?
• Experienced Macintosh system administrator
• Experienced Macintosh support engineer
• Experienced IT Manager

What do I offer your company?
• Deep knowledge of Apple software
• Deep knowledge of Macintosh servers
• Extensive knowledge of Macintosh integration into Windows-centric systems
• Broad knowledge across multiple facets of Information Technology
• Quick learner and self-starter
• Capable of writing for both technical and lay audiences
• Informative and entertaining presenter/teacher

Check out my LinkedIn profile :- http://au.linkedin.com/in/honestpuck/

mountainlionserver.com

mountainlionserver.com

Charles Edge of Krypted.com and Brian Stucki of Macminicolo have started a new joint project “mountainlionserver.com” which brings together all of Charles’ tutorials for Mountain Lion Server.
It is an excellent site with a large number of excellent tutorials for system administrators or home Server users of all levels.

I hope they offer space to host tutorials from others. Charles writes well and often but there are others who write good stuff.

MultiMarkDown and Byword

So now my blog is living in the latest iteration of WordPress courtesy of WordPress.com I can concentrate on writing instead of keeping my blog free of malware.

Of course I spend quite a lot of time working on drafts of my posts. I could use the in-browser editor built in to WordPress but there are better tools on my Mac.

I like to be able to type it all quickly without taking my hands off the keyboard. I love keyboard shortcuts and now I love MultiMarkdown (MMD).

MMD is Fletcher Penney’s extension to John Gruber’s Markdown syntax. With a bit of practice I’ve found it easy to write Markdown syntax, the most useful additions in MMD are tables and footnotes. Using this syntax makes it easy to add web links, headings and emphasised text without having to take my fingers off the keyboard. I can’t emphasise too much how convenient it is to use Markdown to write, let’s list a few advantages.

  • Easier to remember syntax than HTML.
  • Quicker to type syntax than HTML.
  • Leaves your document human readable.
  • Can be opened and edited in any editor.
  • Supports a large percentage of HTML such as bold, italics, lists, code blocks, line breaks, tables and URLs.

So then the search is on to find an editor that supports MMD and works well for a writer (rather than a code jockey). You can find a nice rundown on 35+ Markdown Apps for the Mac on mac.appstorm.

Byword

Currently top of my list is Byword.

Byword fully supports MMD. It has a sort of preview as you type; with headings, lists and emphasised text shown, a single keystroke will show you a full preview. It also nicely dims the characters you insert for formatting.

When you want to put your text into a blog post then a single keystroke will convert your entire document to HTML and add it to the clipboard ready to copy into WordPress.

Byword also has a couple of other nice features for a writer. If you want to focus entirely on your writing it has a full screen mode so you can’t see Facebook open in the browser behind. It also has a paragraph focus mode that dims all your document apart from the paragraph you are working on. It even has line focus and typewriter modes.

Of course it has word and character counts and nicely supports spelling check as you type and all the auto-save and versioning joys of Mountain Lion.

For those that like shortcuts it has some built in to quickly enter the MMD characters for formatting. You hit Command-B and it enters four ‘*’ characters and places the cursor between them, for example.

It also has some nice export options, with the ability to quickly export HTML to the clipboard as well as export to HTML, PDF, RTF, Word and Latex format files. The ability to quickly export the HTML to the clipboard is invaluable when writing blog posts.

All put together it’s an excellent editor and well worth the $10. The authors have also produced a nice version for iOS that I use on the iPad.

Working around a broken keyboard

So two of the keys on my Macbook Air decided to stop working, the comma and the period keys which also give you the lesser than and greater than symbols. I had to find a workaround to give me back those characters.

Thanks to TextExpander and Flycut I found that I can get away with the two broken keys without too much trouble at all. Let me explain how.

TextExpander allows you to define a “shortcut” that gets replaced by any text you like which they call a snippet. Snippets can be bunched together into a group. In my case I defined a single group containing four snippets. I decided that the easiest thing to remember would be the keys either side of the broken pair so now when I type ‘mmm’ I get a comma and ‘///‘ gets me a period, when I do the same with shift down I get the less than and greater than characters.

I then changed my usual setting for this particular group and set “Expand after” to any character.

The one problem with this solution is that TextExpander needs to use the clipboard so the last item on the clipboard will be one of the four characters quite a lot of the time. Enter Flycut.

Flycut us a marvellous free, open source utility that gives you access to more than just the last entry on your clipboard. It puts a menu on the right of the menu bar or you can access them with a pop up. So now when I need to paste something after using my TextExpander shortcut I just have to go to the Flycut menu.

It isn’t as convenient as having the two keys working but it does mean I can continue to use the computer.