How to make php and composer services accessible from an ubuntu container

I need to have an ubuntu container running with php and composer available from with in the container. From the docker documentation, it seems that Compose is provides a way to run containers alongside multiple services, below is a snippet from the docker documentation that mentions about compose

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.

Here is my docker-compose.yml file

version: '3'
    image: ubuntu
      - db
      - kompoza
      - web_server
    image: mysql
    - "3309:3306"
    - MYSQL_ROOT_PASSWORD=password
    - MYSQL_USER=user
    - MYSQL_PASSWORD=password
    - MYSQL_DATABASE=demodb
    image: composer
    image: php

After running docker-compose up all the services fire up, and instantly the kompoza and web_server services exit both with error code 0

container first screen

I need to be able to run php --version and composer --version inside the ubuntu container

I already know that i can install all the software i need in one container using Dockerfile like so

FROM ubuntu:latest
ARG DEBIAN_FRONTEND=noninteractive
ENV TERM=xterm
RUN apt-get update

RUN apt-get install -y curl wget php

# Install Composer
RUN curl -sS | php -- --install-dir=/usr/local/bin --filename=composer

But i prefer to do it the services way as i believe defining services give me more control

How do i achieve that ? and one more question , why did the 2 services exit but mysql didn’t exit ?

continuation of docker-compose outupt,

my account is new, so i can’t upload more than one image.