docker compose - keep running two ways



examples/compose2/docker-compose.yml
version: '3.7'
services:
  one:
    build:
        context: .
        dockerfile: Dockerfile1
  two:
    build:
        context: .
        dockerfile: Dockerfile2
    stdin_open: true
    tty: true

examples/compose2/Dockerfile1
FROM centos:7
RUN yum install -y less vim which net-tools
CMD tail -f /dev/null


examples/compose2/Dockerfile2
FROM centos:7
RUN yum install -y less vim which
WORKDIR /opt


attach to either one of them:


docker-compose exec one sh
ping compose1_one_1