-
Notifications
You must be signed in to change notification settings - Fork 168
Description
Document docs/get-started/migrate-from-docker-compose.md contains multiple issues when providing comparison of docker-compose and Aspire approaches.
Issues with Aspire Equivalent Code
- Section "Multi-service web application":
- frontend and api services are used as docker cotnainers which have images built before docker-compose is started whereas Aspire does not build and use projects
- frontend and api services do not have ports described: in docker-compose they are mapped to static host port, in Aspire they are not
- frontend depends on api, i.e., is not started before api is ready, in Aspire they are started in parallel
- postgres does not have image specified, it is defined by package providing postgres integration and is not guaranteed to be the same as in docker-compose
- postgres username and password are not set
- postgres does not have volume attached
- frontend expects environment variable
API_URL, instead it's provided only withservices__api__<ENDPOINT_NAME>__0variable only if api service haslaunchSettings.json(as the ports are not specified) - api expects environment variable
ConnectionStrings__DefaultConnection, but is provided withConnectionStrings__myappinstead - sentence "Service dependencies: depends_on becomes WithReference() which also configures service discovery." is not true: this line only configures service discovery, it has nothing to do with the startup order whereas short docker-compose depends_on syntax makes service wait until its dependency is ready
- sentence "Data persistence: Volumes are automatically managed by Aspire." is not true: postgres integration provides method
.WithDataVolume()that will attach volume to correct path, but it's not done automatically - it needs to be called explicitly by client code
- Section "Container-based services"
- postgres and redis versions are not specified
- postgres volume is not attached
- redis service port is not mapped to static port on machine in Aspire, but rather to random one
- web service image is built, but Aspire uses already built image from somewhere
- depends_on from docker-compose is not translated to
.WaitFor()in Aspire
- Section "Environment variables and configuration"
- in docker-compose we clearly see names and values for
DATABASE_URL(='postgresql://user:pass@db:5432/myapp') andREDIS_URL(='redis://cache:6379'), in Aspire URLs are not set at all, instead it provides connection stringsConnectionStrings__cache(='localhost:38145,password=w1Naqt...') andConnectionStrings__myapp(='Host=localhost;Port=42055;Username=postgres;Password=5qYKA3...;Database=myapp')
format, username, password, ports - everything is different
- Section "Custom networks and volumes"
-
docker-compose example contains unnecessary network, which can be deleted, it is just mistake in docker-compose and is not benefit of Aspire
docker-compose example should be corrected and Aspire equivalent should be updated accordingly (or say that Aspire does not support this); example of correct usage of custom networks can be found on docs.docker.com:services: proxy: build: ./proxy networks: - frontend app: build: ./app networks: - frontend - backend db: image: postgres networks: - backend networks: frontend: backend:
-
example with external network can be shown (I think, Aspire does not support such scenario)
Other Issues
-
Section "Migration strategy" contains related link to migration from Docker Compose V1 to Docker Compose V2. I'm not sure this is in any way related to the section.
-
Section "Common issues and solutions". Not an issue per se, but it would be good to know how to migrate service which has health check using some command in docker-compose (for custom images or when integration healthcheck is not enough for some reason), e.g.:
services: rabbit: image: rabbitmq:4.1.4-management-alpine healthcheck: test: ["CMD", "rabbitmqctl", "ping"] interval: 30s timeout: 10s retries: 3 start_period: 10s