Update /etc/hosts in a service immediate after a step was started?

I need a way to update /etc/hosts or update DNS entries in already started service after the step was started.

kind: pipeline
type: docker
name: default

services:
  - name: webdriver
    image: selenium/standalone-chrome-debug:3.141.59

steps:
  - name: provision
    image: ubuntu:bionic
    commands:
      - ## A SOME WAY TO UPDATE /etc/hosts in WEBDRIVER service before call selenium go to the specific URL
      - # For example: add a record to /etc/hosts: <ip_of_the_running_step_container> provision 
  - name: step2
    image: ubuntu:bionic
    commands:
      - # For example: add a record to /etc/hosts: <ip_of_the_running_step_container> step2 

Is that theoretically allowed by Docker or Drone?

Docker provides an internal DNS service that allows containers on the same user-defined network to communicate by hostname (which Drone sets to the step name). The following is a working example that demonstrates how pipeline steps can communicate with one-another using the step name as the hostname:

kind: pipeline
name: default

steps:
- name: test
  image: redis
  commands:
  - sleep 5
  - redis-cli -h cache ping
  - redis-cli -h cache set FOO bar
  - redis-cli -h cache get FOO

services:
- name: cache
  image: redis

Thanks, I know about that functionality, but

  1. it will set statically
  2. I would set it dynamically. Let’s say between commands in edges of one step

So, I came up with thought to set up a PowerDNS/CoreDNS service with REST API and update DNS records on the fly. Is this scheme will work?