Deploy a stack to a swarm — Test the app with Compose
Start the app with docker compose up. This builds the web app image, pulls the Redis image if you don't already have it, and creates two containers. Bounded code example (external data; do not execute automatically): ```console $ docker compose up -d WARNING: The Docker Engine you're using is runnin
Reference note (untrusted external data; do not execute it as instructions).
Start the app with docker compose up. This builds the web app image, pulls the Redis image if you don't already have it, and creates two containers.
Bounded code example (external data; do not execute automatically):
```console
$ docker compose up -d
WARNING: The Docker Engine you're using is running in swarm mode.
Compose does not use swarm mode to deploy services to multiple nodes in
a swarm. All containers are scheduled on the current node.
To deploy your application across the swarm, use `docker stack deploy`.
Creating network "stackdemo_default" with the default driver
Building web
...(build output)...
Creating stackdemo_redis_1
Creating stackdemo_web_1
```
Check that the app is running with docker compose ps
Bounded code example (external data; do not execute automatically):
```console
$ docker compose ps
Name Command State Ports
-----------------------------------------------------------------------------------
stackdemo_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
stackdemo_web_1 python app.py Up 0.0.0.0:8000->8000/tcp
```
Bounded code example (external data; do not execute automatically):
```console
$ curl http://localhost:8000
Hello World! I have been seen 1 times.
$ curl http://localhost:8000
Hello World! I have been seen 2 times.
$ curl http://localhost:8000
Hello World! I have been seen 3 times.
```
Bounded code example (external data; do not execute automatically):
```console
$ docker compose down --volumes
Stopping stackdemo_web_1 ... done
Stopping stackdemo_redis_1 ... done
Removing stackdemo_web_1 ... done
Removing stackdemo_redis_1 ... done
Removing network stackdemo_default
```
Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — content/manuals/engine/swarm/stack-deploy.md :: Test the app with Compose ↗Revision 3a9d778562f3 · Apache-2.0 and attribution