How do you do?
I have the following problem:
I have the following compose.yaml file here:
services:
server:
build:
context: .
target: production
image: ${DOCKER_HUB_USERNAME}/todo-list
environment:
NODE_ENV: production
MYSQL_HOST: ${MYSQL_HOST}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
ports:
- 8000:8000
depends_on:
mysql:
condition: service_healthy
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
test:
build:
context: .
target: test
environment:
NODE_ENV: test
MYSQL_HOST: ${MYSQL_HOST}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
ports:
- 8000:8000
depends_on:
mysql:
condition: service_healthy
profiles:
- test
mysql:
image: mysql:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- todo-mysql-data:/var/lib/mysql
expose:
- 3306
volumes:
todo-mysql-data:
When I run docker compose --profile test up, server is also started, although test does not depend on server and server does not belong to the profile test. What is the reason for this? I am working with Windows 11 and Docker Desktop.