2 Containerizing apps

 

This chapter covers

  • How to containerize apps
  • Running your container locally
  • Executing commands in the container context

Containerizing your application—that is, packaging your application and its dependencies into an executable container—is a required step before adopting Kubernetes. The good news is that containerizing your application has benefits beyond being able to deploy it into Kubernetes; it’s a valuable step in its own right, as you’re packaging the application’s dependencies and can then run it anywhere without needing to install those dependencies on the host machine.

Regardless of how you deploy your app, containerizing it means that your developers can begin working on it locally using Docker, enabling them to get started on a new project with no setup beyond installing Docker. It provides easy context switching between the different applications developers are working on, as the environments are completely isolated (figure 2.1). These properties make it a valuable way to improve developer productivity even if you don’t end up deploying your app into production with containers (although you’ll probably want to do that, too).

Figure 2.1 Comparison of multiple projects on a development machine with and without containerization
02-01

2.1 Building Docker containers

2.1.1 Developer setup

2.1.2 Running commands in Docker

2.1.3 Building our own images

2.1.4 Using base images

2.1.5 Adding a default command

2.1.6 Adding dependencies

2.1.7 Compiling code in Docker

2.1.8 Compiling code with a multistage build

2.2 Containerizing a server application

2.2.1 Containerizing an application server

2.2.2 Debugging

2.3 Using Docker Compose for local testing

2.3.1 Mapping folders locally

sitemap