Docker multi-container example
Example typescript app using multiple docker containers
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set docker-ts-multi-container-appcd pulumi-examples/docker-ts-multi-container-appThis example Pulumi application runs two containers locally, one Redis container and one built from the application in the app folder. The application queries the Redis database and returns the number of times the page has been viewed.
Prerequisites#
- Install Pulumi
- Install Node.js
- Install Docker and have it running
Deploying the example#
-
Create a new stack, which is an isolated deployment target for this example:
Terminal window pulumi stack init dev -
Install dependencies:
Terminal window npm install -
Preview and deploy the app via
pulumi up. The preview will take a few minutes, as it builds a Docker container.Terminal window pulumi upUpdating (dev)View Live: https://app.pulumi.com/acmecorp/docker-ts-multi-container-app/dev/updates/1Type Name Status+ pulumi:pulumi:Stack docker-ts-multi-container-app-dev created+ ├─ docker:image:Image appImage create+ ├─ docker:index:Network network create+ ├─ docker:index:RemoteImage redisImage create+ ├─ docker:index:Container redisContainer create+ └─ docker:index:Container appContainer createOutputs:url: "http://localhost:3000"Resources:+ 6 createdDuration: 19s -
View the endpoint URL, and run curl:
Terminal window pulumi stack outputcurl $(pulumi stack output url)Current stack outputs (1)OUTPUT VALUEurl http://localhost:3000I have been viewed 1 times -
Repeat the previous command multiple times to see the number of views increase.
Cleaning up#
Once you are done, you can destroy all of the resources, and the stack:
pulumi destroypulumi stack rm