Chapter 4. Day-to-day Docker

 

This chapter covers

  • Using and managing Docker volumes for persistent shared data
  • Learning your first Docker patterns: the data and dev tools containers
  • Using GUI applications within Docker
  • Manipulating the Docker build cache for fast and reliable builds
  • Visualizing your Docker image lineage in a graph
  • Running commands directly on your containers from the host

As you develop software with Docker you will discover you have various needs that arise. You may grapple with running GUIs from a container, run into confusion around the Dockerfile build cache, want to manipulate your containers directly while in use, wonder about the lineage of your images, want to reference data from an external source, and so on.

This chapter takes you through techniques that show you how to handle these and other concerns that may arise. Think of it as your Docker toolbox!

4.1. Volumes—a persistent problem

Containers are a powerful concept, but sometimes not everything you want to access is ready to be encapsulated. You may have a reference Oracle database stored on a large cluster that you want to connect to for testing. Or maybe you have a large legacy server already set up with binaries that can’t easily be reproduced.

Technique 19 Docker volumes—problems of persistence

Technique 20 Distributed volumes with BitTorrent Sync

Technique 21 Retain your container’s bash history

Technique 22 Data containers

Technique 23 Remote volume mounting using sshfs

Technique 24 Sharing data over NFS

Technique 25 Dev tools container

4.2. Running containers

Technique 26 Running GUIs within Docker

Technique 27 Inspecting containers

Technique 28 Cleanly killing containers

Technique 29 Using Docker Machine to provision Docker hosts

4.3. Building images

Technique 30 Injecting files into your image using ADD

Technique 31 Rebuilding without the cache

Technique 32 Busting the cache

4.4. Staying ship-shape

Technique 33 Running Docker without sudo

Technique 34 Housekeeping containers

Technique 35 Housekeeping volumes

Technique 36 Detaching containers without stopping them

Technique 37 Using DockerUI to manage your Docker daemon

Technique 38 Generate a dependency graph of your Docker images

Technique 39 Direct action—execute commands on your container

4.5. Summary