From the course: Learning Docker Compose: Simplified Multi-Container Application Management
Writing a Docker Compose file - Docker Tutorial
From the course: Learning Docker Compose: Simplified Multi-Container Application Management
Writing a Docker Compose file
Let's see a simple example of docker-compose file. What we see on the screen is very basic, simple code to run one container, nginx in this case. Let's dive into the parts of this compose file. First, we have the version of the compose interpreter we want to use. This line is obsolete now, but I'm keeping it just for the reference to older versions. we don't need it. In the services section, we describe all containers we want to run. In this example, we have only one called web. This is a logical name of the component, which we can use later to reference to this particular service in this compose file. For our first compose to be complete, we need to provide some images to be run. we use a statement image and inform compose that this should be nginx in the latest version. We saw the simple example and to be honest it is not very impressive, is it? So let's see something a little bit more interesting. In this example we can see two services. One is Valky and and second is a custom application we build. Valky is a in-memory keystore database. It is a fork of Redis. In this database, we store values which come from web application. This is one of the use cases. Other can be storing the temporary sessions, cache for databases to faster retrieve data, that page cache or keeping application metadata. In this example, we see many of the most important elements of Compose like port exposures, just here. Volume creation, for example, here and here. Network definitions. We have one here and here. Health checks. Very important part. And also variables. Like this one. We will learn how to configure all of them but first Would it be nice to know how to actually run this application?