Trigger a container whenever another container starts

I have installed Hashi Corp vault using docker. To use vault it need to be unsealed every time the container starts.

So i want to execute a script which unseals vault when the container is started.

Is there an approach, where i can execute the script when the container starts.

I had this solution but not sure whether this is possible.

  1. Container A is a vault container
  2. Container B is a python container and this container unseals vault and stops

When container A starts i want container B to start. Is there a way to achieve this.

Any suggestion please

vault service should have healthcheck and python container should start when vault container is healthy

See this answer for exact syntax.

Saw this solution, but in my case the container B just unseals the vault and then shuts down and again it has to start only when the container A restarts.

So if i apply restart condition for container B, it starts every time but in my case it has to restart only when container A starts and unseal Vault in container A and finally stop.