version: '3'
services:
a:
image: ubuntu
command: sleep 999
b:
image: ubuntu
command: echo hello
depends_on:
- a
$ docker-compose up --exit-code-from b; echo $?
WARNING: using --exit-code-from implies --abort-on-container-exit
Starting tmp_a_1 ... done
Starting tmp_b_1 ... done
Attaching to tmp_a_1, tmp_b_1
b_1 | hello
tmp_b_1 exited with code 0
Aborting on container exit...
Stopping tmp_a_1 ... done
0```