Customize the app and redeployEstimated reading time: 3 minutes
In this step, we’ll make a simple change to the application and redeploy it. We’ll change the focus of the poll from Cats or Dogs to .NET or Java.
In the real world, you might do this by making code changes and rebuilding to create new images, or new versions of the same images.
For our example, we’ve done this for you. We already have a different version of
the application available as built images. So, all you need to do is reconfigure
docker-stack.yml to point to the new images, then redeploy.
Update docker-stack.yml to reference new images
Go back to
docker-stack.yml and replace the
before tags on both the
result images to reference
after tags. These new image tags will call different versions of the images.
Run the same deploy command again to run the app with the new configuration.
docker stack deploy --compose-file docker-stack.yml vote
The output will look similar to this:
docker@manager:~$ docker stack deploy --compose-file docker-stack.yml vote Updating service vote_redis (id: md73fohylg8q85aryz07852o0) Updating service vote_db (id: gny9ieqxancnufrg1oeazz9gq) Updating service vote_vote (id: 0ig0s4gb10q8auek9tris5i8z) Updating service vote_result (id: lqwxjmmdhmegs2aw0a6ehipsp) Updating service vote_worker (id: 8u4cfu60dtliz77x1o74kiwpr) Updating service vote_visualizer (id: ya2vt9z2b4to248tccjjeqitw)
Try it out
Take the app for another test drive.
You’ll see the new voting choices for Java and .NET at
And the related results at
The visualizer at
<MANAGER-IP>:8080 will show some differences, such as
updates to the containers, and some services might have moved between the
manager and the worker.
However, the PostgreSQL container (
vote_db) and the
vote_visualizer) will still be running on the manager because of
[node.role == manager] constraints on those services, which we
did not change.
A deeper dive voting app walkthrough is available on Docker Labs as Deploying an app to a Swarm. The lab walkthrough provides more technical detail on deployment configuration, Compose file keys, the application, stack and services concepts, and networking.
Source code for the Voting App (to go along with the lab walkthrough) is also available on Docker Labs.
The images you used are available on Docker Hub. When you ran
docker-stack.ymlyou pulled those images from Docker Hub.
For more about swarm mode, start with the Swarm mode overview.
- To learn about shutting down the sample app and cleaning up, see Graceful shutdown, reboot, and clean-up.