A special Docker Compose configuration has been created that allows you to test your skills installing MongoDB. This container is drawn from the latest long-term support (LTS) version of the Ubuntu Linux image on Docker Hub. It also has the necessary prerequisites for installing MongoDB. The files to create and run this container are located in the source code repository for the book, at /path/to/repo/chapters/02.Â
Let's first have a look at the docker-compose.yml file first. It is in YAML file format (as is the mongod.conf file), so you must pay careful attention to indents. The first line indicates the version of Docker Compose. After that, we define services. The only service defined creates a container named learn-mongo-installation-1 and an image named learn-mongodb/installation-1. Two volumes are mounted to allow data to be retained even if the container is restarted.
Also, a file in the common_data directory is mounted as /etc...