Skip to content

Instantly share code, notes, and snippets.

Working With the Docker Image Cache

When building Docker images, you'll likely need to do at least a few iterations on your Dockerfile before you get everything perfect. If you know how to use the local image cache to your advantage it can significantly speed up the Dockerfile code/build/test cycle.

In this article I'll discuss how the Docker image cache works and then give you some tips for using it effectively.

Caching Image Layers

Each instruction in your Dockerfile results in a new image layer being created and added to your local image cache. That image then becomes the parent for the image created by the next instruction (see my previous article for a detailed explanation of the image creation process). Let's look at an example:

FROM debian:wheezy
@rheinwein
rheinwein / kubernetes-blog.md
Last active August 3, 2021 03:21
An Intro to Kubernetes

#Using Kubernetes Developed by Google, Kubernetes is a cluster manager for your Docker containers. With it, you can schedule and deploy any number of container replicas onto a node cluster. The name Kubernetes originates from Greek, meaning "helmsman" or "pilot," and that's the role it will fill in your Docker workflow. Kubernetes is a solution for overseeing and managing multiple containers at scale, rather than just working with Docker on a manually-configured host.

What Docker Is... and What it Isn't

Docker and its ecosystem are great for managing images, and running containers in a specific host. But these interactions are local; Docker alone can't manage your containers across multiple nodes, or schedule and manage tasks to be completed across your cluster. Docker alone works best when you're able to manually manipulate and configure the host. But we all know that only takes us so far.

In order to manage a Docker workload on a distributed cluster,

@rheinwein
rheinwein / port-forwarding.md
Last active August 29, 2015 14:07
Port Forwarding in Panamax

Private Networks and Port Forwarding in Panamax

Panamax v0.2.3 brings some great changes to networking and port bindings that will make your time using Panamax even better. Panamax can now create a private network for you, and we've added support for automatic port mapping. Gone are the days of manually configuring your VM in order to peer into your Docker containers.

###The old way Prior to version 0.2.1, accessing your Panamax application on your local machine could be a bit of a hassle. We relied on the NAT adaptor and leveraged port forwarding to access CoresOS and the Panamax UI and API. This added some extra steps in order for you to access the applications running in Panamax.

![](https://camo.githubusercontent.com/0845a257d72b390007961ee49626abc78df3029d/68747470733a2f2f63616d6f2e67697468756275736572636f6e74656e742e636f6d2f366438343839396330626461336563396135663032663437653564383039366664613265626665622f3638373437343730336132663266373036313665363136643631373832653633363132653734363936353732333332

@rheinwein
rheinwein / remote.md
Last active August 29, 2015 14:09
Remote Agent Post

#Panamax Announces Remote Agent Deployments

The Panamax team is happy to announce the v.0.1 launch of the Panamax Remote Agent toolset, consisting of the Panamax Remote Agent and adapters for deploying to both Kubernetes and to a CoreOS cluster using Fleet. This marks the next step in creating a tool that simplifies Docker management for humans. Keep in mind that both Panamax and the Remote Agent are nowhere near 1.0.

As mentioned in a previous post about the evolutionary path of Panamax, the core team agreed that Panamax templates — the heart of what makes working with Panamax simple and great — should be agnostic to host, orchestration, and cluster management technology.

Previously, Panamax was able to deploy to a local, single-node configuration using Core

@rheinwein
rheinwein / marathon.md
Last active August 29, 2015 14:14
Marathon Blog

#Deploying to Your Mesosphere Cluster with CenturyLink’s Panamax

Panamax is a powerful Docker workflow tool that makes creating containerized applications easy, and deploying them even easier. An open source project from CenturyLink Labs, Panamax allows you to create application templates, configure your containers, test them on your local machine, and deploy your application to remote hosting targets. The Panamax team is happy to announce that a Marathon remote deployment adapter is now available, making it possible to deploy to your Mesosphere cluster with Panamax, right from your browser.

###How Panamax Works Panamax runs locally on your development machine. When you install Panamax, a small virtual machine running CoreOS is booted to hold three Docker containers -- the UI, API, and cAdvisor (for monitoring). When you introduce remote deployments, this local Panamax client will talk to a remote agent and adapter -- running in the target environment -- via SSL.

Starting with local examples, you'll lear

@rheinwein
rheinwein / imagelayers.md
Last active October 20, 2016 16:32
Introducing ImageLayers

ImageLayers.io is a new project from the team at CenturyLink Labs. This utility provides a visualization in the browser of user-specified Docker Images and their layers. This visualization provides key information on the composition of a Docker Image and any commonalities between them. ImageLayers.io allows Docker users to easily discover best practices for image construction, and aid in determining which images are most appropriate to use in their specific use cases.

##What are Layers? Docker uses a union file system for managing images. Each layer of your image is the result of some action taken during the build. This could be installing a package, copying files from a local or remote source, or setting an environment variable. Each action creates a new layer in the file system; layers reference their parents and are cached, so they may be used as a part of an entirely different image.

There is a direct correlation between your Dockerfile and the number of layers in your image. Docker offers some advice o

ImageLayers.io is a new project from the team at CenturyLink Labs. This utility provides a browser-based visualization of user-specified Docker Images and their layers. This visualization provides key information on the composition of a Docker Image and any commonalities between them. ImageLayers.io allows Docker users to easily discover best practices for image construction, and aid in determining which images are most appropriate for their specific use cases.

##What are Layers? Docker uses a union filesystem for managing images. Each layer of an image is the result of some action taken during the build. This could be installing a package, copying files from a local or remote source, or setting an environment variable. Each action creates a new l

Much of the focus of Docker is on the process of packaging and running your application in an isolated container. There are countless tutorials that explain how to run your application in a Docker container, but very few that discuss how properly stop your containerized app. That may seem like a silly topic -- who cares how you stop a container, right?

Well, depending on your application, the process by which you stop your app could be very important. If your application is serving HTTP requests you may want to complete any outstanding requests before you shutdown your container. If your application writes to a file, you probably want to ensure that the data is properly flushed and the file is closed before your container exits.

Things would be easy if you simply started a container and it ran forever, but there's a good chance that your application will need to be stopped and restarted at some point to facilitate an upgrade or a migration to another host. For those times when you need to stop a run

Keybase proof

I hereby claim:

  • I am rheinwein on github.
  • I am rheinwein (https://keybase.io/rheinwein) on keybase.
  • I have a public key whose fingerprint is 0B51 FBA6 00A1 6957 671B 9007 959D DA16 B581 19FC

To claim this, I am signing this object: