第1页
Maintaining the Official Node.js Docker Image
Christopher Horrell
Manager, Solutions Engineering Joyent Inc.
第2页
Joyent Inc.
• Container company (since ~2006)
• Joyent Public Cloud
• Private Cloud Software, Smart Data Center (https://github.com/ joyent/sdc)
第3页
• Part of Smart Data Centre and available in Joyent Public Cloud
• Run Docker images natively on SmartOS Zones • Turns an entire data center into a Docker host • Or run non-Docker Linux containers at bare-
metal speed!
第4页
Solutions Engineering
• The "image team"
• Core members are myself and Derek Crudgington (https://github.com/dcrudgington)
• Build images for Joyent Public Cloud, Smart Data Center, and SmartOS - SmartOS, KVM Linux (Debian, CentOS) FreeBSD and Windows Images - Linux (Triton!) Container images
• And maintain the official Docker Node.js Image!
第5页
Docker Node.js Image
• The registry: https://registry.hub.docker.com/ _/node/
• GitHub: https://github.com/joyent/docker-node • Kind of popular!
第6页
The Hand Off!
• Took over an existing official image, which had some advantages: - Had some great scripts for updating the image - Everything was pretty well established
• Great resources: - https://github.com/docker-library/official-images - IRC channel #docker-library on Freenode
• Some prior history we had to get familiar with: - Choice of base image (buildpack-deps:jessie) balances general usefulness vs. image size (more on that later) - Different tags/variants (more on those later)
第7页
Image Update Workflow
• Update image Dockerfiles → Generate new library file → make pull request to official Library
• The workflow was a bit new for us, but we settled in nicely
• Looking to automate image updates and testing. Some interesting options with Jenkins
第8页
Some Additions
• Did not want to introduce too much change to the images
• Derek updated the update.sh and generatestackbrew-library.sh scripts (now Macfriendly)
• Added simple build test to ensure all the images build. Test 0
• Looking at using Serverspec for testing and automating things (more on that later)
第9页
Are you starting from scratch?
• Great resources: Docs, irc channel, other official images
• We had the benefit of taking over an established image which follows Docker best practices
• You need to consider things like: - What base image to use? Use an official base image (Debian, Ubuntu, CentOS etc), one that makes sense for the overall image. - Dockerfile best practices
• What Tags and Variants will you have?
• Include Tests! At very least, does it build?
第10页
Tags are Great!
• Offer different versions:
docker pull node:0.10.38 docker pull node:0.12.4 docker pull node:latest # -> 0.12.4
第11页
Variants: Also Great!
• docker pull node:0.12.4-slim
# A "leaner" version of node:0.12.4 docker pull node:0.12.4-wheezy # Alternative if prefer Debian Wheezy over Jessie
• Document your tags and variants
• Usage might not be obvious to anyone browsing registry (or GitHub repo)
• Good examples:
- https://registry.hub.docker.com/_/node/ - https://registry.hub.docker.com/_/iojs/
第12页
Image Size?
• Keep the image reasonably small: A balance between size and usefulness
• node:latest etc. is built from buildpack-deps:jessie - Big, lots of packages installed, makes building things like npm modules easy. That's super convenient
• node:slim variant (FROM debian:jessie) is a nice option to build on if you know what you want installed and prefer to keep things lean
• Alpine Linux is SUPER small (~5MB!), might probably not be suitable for your app or use case, but worth looking at.
第13页
User Feedback
• Monitor GitHub issues for user feedback -- this works pretty well
• GitHub issues are great way for responding to or integrating user feedback
• Consider creating an F.A.Q for recurring GitHub issues about design decisions (like choice of base image, etc.)
第14页
Testing • At the very least: Does it build?
• Test Driven Development applied to Dockerfiles/ Images: - https://workshop.avatarnewyork.com/post/ test-docker-images-with-circleci/ - http://blog.wercker.com/2013/12/23/Testdriven-development-for-docker.html - https://workshop.avatarnewyork.com/post/ test-docker-images-with-circleci/
• Continuous Integration with Jenkins?
第15页
Serverspec
• http://serverspec.org
• Great testing option, based on Rspec
• Been using it to test our SmartOS/KVM images (e.g., https://github.com/joyent/smartos-image-tests)
• Has Docker support! - Create a test suite that builds your image (test 0) provisions a container, runs test against a container
• Great option to validate your images before publishing
• Speaking of the Docker Node image...
第16页
Interesting Plot Twist!
❤️
• Node.js and io.js will be merging!
第17页
What will happen to the Node.js image?
• Will eventually move under the Node.js foundation (https:// github.com/nodejs/),
• Will be maintained by the Node.js Docker Working Group (I'm a member!)
• The Official io.js and Node.js images will probably track separately until the big merged release
• Working Group is maintaining the Official io.js image, doing a great job, and the Node.js and io.js images are pretty similar (tags, variants, etc.)
• It should be a pretty smooth transition (docker pull node:latest and docker pull node:0.10.38 will still work :)
• Longer term? Still offer older Node.js releases but a lot of things the Working group will need to figure out.
第18页
Thank you
Christopher Horrell christopher@joyent.com, @chorrell