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.

version: '2.4'
   image: sitecore-xm-sqldev:9.2.0-windowsservercore-1903
     - .\data\sql:C:\Data
   mem_limit: 2GB
     - "44010:1433"
   image: sitecore-xm-solr:9.2.0-nanoserver-1903
     - .\data\solr:C:\Data
   mem_limit: 1GB
     - "44011:8983"
   image: sitecore-xm-cm:9.2.0-windowsservercore-1903
     - .:C:\license
     - .\data\cm:C:\inetpub\wwwroot\App_Data\logs
     - "44000:80"
     - sql
     - solr
     name: nat

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> u

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
Oh, so that’s it? Yep.

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:

Ciao, amigos!

In Conclusion

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.

All of this of course would not be possible with the folks behind the GitHub Repo building all these Dockerfiles. Hats off to Bart and Per for all their hard work!

This is a post in the “Yet Another Sitecore Docker Series.” Other Posts include

Facebooktwitterredditlinkedinmail Facebooktwitterredditlinkedinmail