It feels pretty good to get this whole thing running. Let’s make it easier. Let’s meet Docker Compose. Docker Compose is a utility that essentially helps with orchestration of containers. That just sounds badass!
Docker Compose uses a docker-compose file which in the YAML format. Here’s an example we’ll be working with. The current GitHub repo has a variety of them found in \windows\tests\9.x.x which is where I got this from.
Woooo that looks fun! Let’s start at the top in the services section. Each element of services section is a container to spin up. Looking back at our command lines, we can see how the image parameter translates to tag, volumes translates to mounts, and ports translate to publish. this all makes sense! How do we actually run this sucker?
docker-compose -f <composefile.yml> up
A couple things to note:
- I like to run the docker-compose command from the same folder as the YML file. This -f switch let’s the world know where that file is, if you feel brave.
- Your going to need the folder structure in place for mounts, just like before. I’m sure there’s a way to force creation, I just don’t know it, yet.
- The license file goes right next to this YML file. Notice the “.” in the first cm volume? That’s why.
- The above command is not detached at this point. It means when the command exits (you hit Ctrl+C) the containers will not exist. That’s kind neat, but kinda scary? Maybe?
Let’s run this detached now:
docker-compose -f <composefile.yml> up -d
We can hit our browser again, and all is well! Go ahead and check the folder structure, it’ll have all the solr, SQL and log files you’d expect. All in one place. Which is pretty nice if you’re organized unlike me.
If you want to tear down the whole environment, go ahead:
docker-compose -f <composefile.yml> down
Which gets you something like this:
I really hope this was a helpful series. Writing it was quite fun, especially since I’ve not really done work with docker before. This is by far not the end of the road, and I fully entrust that the GitHub repo will evolve over time; they’re rockstars over there. For now, i hope this look at docker and Sitecore gives you some better understanding of how the two can place super nice together. I mean like kids-in-the-sandbox-all-happy-on-Capri-Sun happy.
This is a post in the "Yet Another Sitecore Docker Series." Other Posts include
- Part 1: The Beginning
- Part 2: Running Docker
- Part 3: Layers are Yum
- Part 4: Composing an Image
- Part 5: Deconstructing a Dockerfile
- Part 6: Simply Solr
- Part 7: Smooth as SQL
- Part 8: It's Sitecore Time
- Part 9: Compose all the Things