Now that we know how Docker Hub serves images to us, let's look at how to integrate them into our code via three methods. The first will be a Dockerfile, the second will be in the docker-compose.yaml
file, and the last will be straight into a Puppet manifest.
In this topic, we will look at using nginx in a basic Dockerfile. In a Dockerfile, we need to add a few things. The first is the image that we are basing our application on; for us it will be nginx. The second is a maintainer. It should look like as shown in the following screenshot:
As the base nginx image has already got port 80 and 443 exposed, we will not need that configuration for our Dockerfile. The next thing we will add is a simple run
command to update the packages in the container. As its base OS is Debian, we will add the command shown on line 5 in the following screenshot:
As we are building a simple application, this is all that we are going to add to our Dockerfile. There are heaps...