I have a docker-compose
file that creates two instances, one for webserver
and another for database
.
When I run docker ps
I get this kind of output:
7cb1fb603a98 apache "/usr/bin/dumb-init …" 3 minutes ago Up 3 minutes (healthy) 0.0.0.0:8080->8080/tcp compose_webserver_1
74f3bbe506eb postgres:13 "docker-entrypoint.s…" 6 minutes ago Up 16 minutes (healthy) 5432/tcp compose_postgres_1
If I run docker images
:
REPOSITORY TAG IMAGE ID CREATED SIZE
webserver latest 17dc61fa0139 2 minutes ago 2.05GB
database latest 17dc61fa0139 2 minutes ago 2.05GB
I see that both services share image_id
. In my docker-compose.yml
I have setup:
build:
context: .
dockerfile: Dockerfile-test
To run some ADD
before creating it. Then, I am creating my own image using another image as a base in the FROM
statement.
Once I have my new image with the main content, but also with my added requirement.txt
, and other stuff I push it to ECR
repository.
Then instead of working with my first two docker containers I work with a single container that has been created using these new image in my ECR repository.
It have both services in a single container, despite in my original docker-compose up --build
it raised two containers. Why this is happening?
Is this correct, or should I force with the command statement to create two container instances from the new pulled imaged created by me? For example having always two container instances can allow me to then exchange the postgres container to one mysql for example.