You ran some containers in the last chapter and used Docker to manage them. Containers provide a consistent experience across applications, no matter what technology stack the app uses. Up till now you’ve used Docker images that I’ve built and shared; in this chapter you’ll see how to build your own images. This is where you’ll learn about the Dockerfile syntax, and some of the key patterns you will always use when you containerize your own apps.
We’ll start with the finished version of the image you’ll build in this chapter, so you can see how it’s been designed to work well with Docker. The try-it-now exercises all use a simple application called web-ping, which checks if a website is up. The app will run in a container and make HTTP requests to the URL for my blog every three seconds until the container is stopped.
You know from chapter 2 that docker
container
run
will download the container image locally if it isn’t already on your machine. That’s because software distribution is built into the Docker platform. You can leave Docker to manage this for you, so it pulls images when they’re needed, or you can explicitly pull images using the Docker CLI.
Try it now:
docker image pull diamol/ch03-web-ping