services: master: build: . container_name: pdc-master # REMOVED the 'hostname:' line volumes: - ./hostfile:/app/hostfile # ADDED the 'environment:' block environment: - FRIENDLY_NAME=pdc-master command: > sh -c "/usr/sbin/sshd & sleep 5 && mpirun -np 5 --hostfile /app/hostfile --allow-run-as-root /app/task1" networks: - pdcn worker1: build: . container_name: pdc-worker1 # REMOVED the 'hostname:' line # ADDED the 'environment:' block environment: - FRIENDLY_NAME=pdc-worker1 command: /usr/sbin/sshd -D networks: - pdcn worker2: build: . container_name: pdc-worker2 # REMOVED the 'hostname:' line # ADDED the 'environment:' block environment: - FRIENDLY_NAME=pdc-worker2 command: /usr/sbin/sshd -D networks: - pdcn worker3: build: . container_name: pdc-worker3 # REMOVED the 'hostname:' line # ADDED the 'environment:' block environment: - FRIENDLY_NAME=pdc-worker3 command: /usr/sbin/sshd -D networks: - pdcn worker4: build: . container_name: pdc-worker4 # REMOVED the 'hostname:' line # ADDED the 'environment:' block environment: - FRIENDLY_NAME=pdc-worker4 command: /usr/sbin/sshd -D networks: - pdcn networks: pdcn: driver: bridge