‫Now that you've seen all the ways to create secrets in our stack, I'm going to give you a little
‫assignment on using secrets with a previous stack you've used.
‫You remember our friend Drupal, the compose file we used earlier, in compose assignment 2.
‫I want you to take that, and we're going to actually extend it and make it stack ready.
‫First, we're not going to build a custom image right now.
‫We're just going to use the default Drupal.
‫Then you would need to remove the build section from your compose file. Then I'd like you to
‫add the secret at the bottom, and when you do that, instead of using a file-based secret, put in external.
‫You can also look that up in the resources for this section.
‫It'll be the documentation on Docker's website all about secrets.
‫It'll show you the formatting in there of a compose file. So you use external, which means we actually
‫have to use the CLI to put that secret in. Then you're going to pass the password file,
‫that is the secret file, into postgres, using the environment variable.
‫So, you'll need to add that to the postgres section.
‫Then before we actually deploy the stack, you need to actually put the secret into the swarm.
‫This will be a case where we're not using a secret file. We're simply going to manually, as an operator,
‫add the secret to our swarm. Then in the stack file,
‫we're going to actually specify that, using the external at the bottom.
‫Once you've got it all edited the way you think it's correct and you're ready to test it, just copy it
‫into a new YAML file on your swarm node1. Try and do a stack deploy and see if it works.
‫You may not get it right the first time, and that's fine.
‫A lot of times I won't either.
‫I have to go back and revise it, and then try a deployment again. The errors that you'll get back
‫are usually pretty good at telling you what your problems are.
‫For me, it's usually that my YAML isn't formatted correctly or something silly like that.
‫If you have any issues, don't hesitate to just watch the video after this where I actually walk through
‫this assignment for you.
‫But I think your brain will work better if you try it yourself and get your mind working about how you
‫would actually solve this assignment yourself.
‫Good luck, and I'll see in the next lecture.