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'
services:
web:
image: ubuntu
links:
- db
- kompoza
- web_server
db:
image: mysql
ports:
- "3309:3306"
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_USER=user
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=demodb
kompoza:
image: composer
web_server:
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
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 https://getcomposer.org/installer | 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 ?