Skip to main content

Update's in Docker Compose V3

What’s new in Docker Compose v3

In this blog, we’ll discuss new features added in Docker Compose v3. Docker compose added the feature of stack deployment with swarm.
To achieve this, we need to create a file named, docker-stack.yml and specify the deploy key, which would allow you to specify various properties of a swarm deployment in docker-stack.yml file.
For deploying this, you simply need to run the docker-stack deploy command with this docker-stack.yml file to pull the referenced images and launch the services in a swarm as configured in the .yml.

deploy key

The deploy key allows you to specify configuration related to the deployment and running of services. The deploy key can also be used to constrain some services to run only on the manager node.
Specify configuration related to the deployment and running of services. This only takes effect when deploying to a swarm cluster with `docker stack deploy` command and is ignored by docker-compose up and docker-compose run commands.
deploy:
  mode: replicated
  replicas: 5
  update_config:
    parallelism: 2
    delay: 10s
  restart_policy:
    condition: on-failure
Several sub-options available are mentioned below:

mode

mode is specified either as global (exactly one container per swarm node) or replicated (a specified number of containers). Default is replicated.
mode: global

replicas

To specify the number of containers that should be running at any given time.
replicas: 5

placement

To specify the placement constraints.
placement:
  constraints:
    - node.role == manager
    - engine.labels.operatingsystem == ubuntu 16.04

update_config

To configure how the service should be updated. Useful for configuring rolling updates.
  • parallelism: The number of containers to update at a time.
  • delay: The time to wait between updating a group of containers.
  • failure_action: What to do if an update fails. Either continue or pause Default is pause.
update_config: 
  parallelism: 2 
  delay: 10s

resources

To configure resource constraints. This replaces the older resource constraint options in Compose files prior to version 3 (cpu_shares, cpu_quota, cpuset, mem_limit, memswap_limit).
resources:
  limits:
    cpus: '1.5'
    memory: 500M
  reservations:
    cpus: '1.0'
    memory: 200M

restart_policy

To configure whether and how to restart containers when they exit.
  • condition: One of none, on-failure or any. Default is any.
  • delay: How long to wait between restart attempts. Default is 0.
  • max_attempts: How many times to attempt to restart a container before giving up. Default is never give up.
  • window: How long to wait before deciding if a restart has succeeded. Default is decide immediately.
restart_policy: 
   condition: on-failure 
   delay: 5s 
   max_attempts: 3 
   window: 120s

labels

To specify labels for the service. These labels will be set only on the service, and not on any containers for the service.
version: "3"
services:
  web:
    image: web
    deploy:
      labels:
        com.example.description: "This label will appear on the web service"
To set labels on containers instead, use the labels key outside of deploy:
version: "3"
services:
  web:
    image: web
    labels:
      com.example.description: "This label will appear on all containers for the web service"

“docker stack deploy” command

docker stack deploy command (supported only by compose v3) is used to deploy with docker-stack.yml.
This command does not support the build key supported in Compose files, which builds based on a Dockerfile. You need to use pre-built images with docker stack deploy

Popular posts from this blog

How to read or extract text data from passport using python utility.

Hi ,  Lets get start with some utility which can be really helpful in extracting the text data from passport documents which can be images, pdf.  So instead of jumping to code directly lets understand the MRZ, & how it works basically. MRZ Parser :                 A machine-readable passport (MRP) is a machine-readable travel document (MRTD) with the data on the identity page encoded in optical character recognition format Most travel passports worldwide are MRPs.  It can have 2 lines or 3 lines of machine-readable data. This method allows to process MRZ written in accordance with ICAO Document 9303 (endorsed by the International Organization for Standardization and the International Electrotechnical Commission as ISO/IEC 7501-1)). Some applications will need to be able to scan such data of someway, so one of the easiest methods is to recognize it from an image file. I 'll show you how to retrieve the MRZ information from a picture of a passport using the PassportE

How to generate class diagrams pictures in a Django/Open-edX project from console

A class diagram in the Unified Modeling Language ( UML ) is a type of static structure diagram that describes the structure of a system by showing the system’s classes, their attributes, operations (or methods), and the relationships among objects. https://github.com/django-extensions/django-extensions Step 1:   Install django extensions Command:  pip install django-extensions Step 2:  Add to installed apps INSTALLED_APPS = ( ... 'django_extensions' , ... ) Step 3:  Install diagrams generators You have to choose between two diagram generators: Graphviz or Dotplus before using the command or you will get: python manage.py graph_models -a -o myapp_models.png Note:  I prefer to use   pydotplus   as it easier to install than Graphviz and its dependencies so we use   pip install pydotplus . Command:  pip install pydotplus Step 4:  Generate diagrams Now we have everything installed and ready to generate diagrams using the comm

Python questions and answers part 3

Q1).What is Python? Ans1:   Python  is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed to be highly readable. It uses English keywords frequently where as other languages use punctuation, and it h as fewer syntactical constructions than other languages. Q2).Name some of the features of Python. Ans2:  Following are some of the salient features of  python It supports functional and structured programming methods as well as OOP. It can be used as a scripting language or can be compiled to byte-code for building large applications. It provides very high-level dynamic data types and supports dynamic type checking. It supports automatic garbage collection. It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java. Q3).Do you have any personal projects? Really? Ans3: This shows that you are willing to do more than the bare minimum in terms of keeping your skillset up to date. If you work on personal projects and