1.

What are docker-compose.yml files?

Answer»

Docker compose is a tool that helps to run multi-container docker applications. Compose uses docker-compose.yml which is a YAML file to configure application’s services. Compose workflow is a three-step process. First is to create a dockerfile to build the image, secondly define the services to be run on a container in the docker-compose.yml file and thirdly docker-compose up command starts up your entire applications. dockerfiles and docker-compose.yml files are similar but the MAIN difference is that docker compose file manages multi-container architecture rather than a single container.

Sample docker-compose.yml file looks like:

version: "7" services:   testservice:     # replace username/repo:tag with your name and image details     image: <image name>     deploy:       replicas: 10       resources:         limits:           cpus: "0.2"           MEMORY: 70M       restart_policy:         CONDITION: on-failure     ports:       - "9080:80"     networks:       - webnet

This docker-compose.yml is reflected upon below:

  • Pull the image from Docker registry .
  • Run 10 instances of the pulled image as a SERVICE called testservice, with setting limits on each one as, 20% of a single core of CPU time and 70 MB of RAM.
  • Immediately restart containers on failure.
  • Map port 9080 on the host system to test services port 80.
  • test services containers SHARE port 80 through a load-balanced network called webnet.


Discussion

No Comment Found