@@ -41,6 +41,7 @@ Define and run multi-container applications with Docker.
4141| :-----------------------| :--------------| :--------| :----------------------------------------------------------------------------------------------------|
4242| ` --ansi ` | ` string ` | ` auto ` | Control when to print ANSI control characters ("never"\| "always"\| "auto") |
4343| ` --compatibility ` | | | Run compose in backward compatibility mode |
44+ | ` --dry-run ` | | | Execute command in dry run mode |
4445| ` --env-file ` | ` stringArray ` | | Specify an alternate environment file. |
4546| ` -f ` , ` --file ` | ` stringArray ` | | Compose configuration files |
4647| ` --parallel ` | ` int ` | ` -1 ` | Control max parallelism, -1 for unlimited |
@@ -169,3 +170,49 @@ If flags are explicitly set on the command line, the associated environment vari
169170
170171Setting the `COMPOSE_IGNORE_ORPHANS` environment variable to `true` will stop docker compose from detecting orphaned
171172containers for the project.
173+
174+
175+ # ## Use Dry Run mode to test your command
176+
177+ Use `--dry-run` flag to test a command without changing your application stack state.
178+ Dry Run mode will show you all the steps Compose will apply by executing the command, for example :
179+ ` ` ` console
180+ $ docker compose --dry-run up --build -d
181+ [+] Pulling 1/1
182+ ✔ DRY-RUN MODE - db Pulled 0.9s
183+ [+] Running 10/8
184+ ✔ DRY-RUN MODE - build service backend 0.0s
185+ ✔ DRY-RUN MODE - ==> ==> writing image dryRun-754a08ddf8bcb1cf22f310f09206dd783d42f7dd 0.0s
186+ ✔ DRY-RUN MODE - ==> ==> naming to nginx-golang-mysql-backend 0.0s
187+ ✔ DRY-RUN MODE - Network nginx-golang-mysql_default Created 0.0s
188+ ✔ DRY-RUN MODE - Container nginx-golang-mysql-db-1 Created 0.0s
189+ ✔ DRY-RUN MODE - Container nginx-golang-mysql-backend-1 Created 0.0s
190+ ✔ DRY-RUN MODE - Container nginx-golang-mysql-proxy-1 Created 0.0s
191+ ✔ DRY-RUN MODE - Container nginx-golang-mysql-db-1 Healthy 0.5s
192+ ✔ DRY-RUN MODE - Container nginx-golang-mysql-backend-1 Started 0.0s
193+ ✔ DRY-RUN MODE - Container nginx-golang-mysql-proxy-1 Started Started
194+ ` ` `
195+ You could see that the first step will be to pull the image defined by `db` service, then build the `backend` service.
196+ After that, containers will be created, the `db` service started and the `backend` and `proxy` will wait until `db` service is healthy to start.
197+
198+ The Dry Run mode is not supported by all commands, especially by the command which doesn't change the state of a Compose stack
199+ such as `ps`, `ls`, `logs` for example.
200+
201+ Here the list of commands supporting `--dry-run` flag :
202+ * build
203+ * cp
204+ * create
205+ * down
206+ * exec
207+ * kill
208+ * pause
209+ * pull
210+ * push
211+ * remove
212+ * restart
213+ * run
214+ * start
215+ * stop
216+ * unpause
217+ * up
218+
0 commit comments