"pid is not a child of this shell" error occurs when using parallel of shell

Host OS: Ubuntu 14.04 server
Docker OS: Ubuntu 14.04
Docker Version: Docker CE 17.03

Steps to reproduce:

  1. enter the docker

  2. create a shell script test.sh using multi-processes, e.g.
    #!/bin/bash
    pids=()
    for i in seq 1 200
    do
    {
    echo ‘hello world’
    }&
    pids+=($!)
    done
    echo ${pids[*]}
    wait

  3. chmod +x test.sh, run this script.

  4. error occurs, saying “pid is not a child of this shell”

More information found:

  1. This problem happens with Host OS ubuntu 16.04, Docker OS ubuntu 16.04, and Docker version 18. I’ve tried several combinations of host os, docker os, and docker app version.

  2. In my case, this problem does not occur while using small parallel, e.g. 10;
    It comes to me when set 67 or more parallel processes.

Could anyone please help me if you have any idea? Thank you so much!