Saturday, August 10, 2019

Local Docker Registry for Sitecore Images

    There are a lot of articles how to run Sitecore on Docker. But no one explain, how it is possible to do without paid account on Docker hub(or alternative).
    If for some reasons, you don't want to use Docker Hub(or alternative) for hosting your Sitecore images and want to host them locally, this article is for you. Here are steps that you need to achieve it:
  1. Run registry-windows container. It will be your local "Docker Hub".
    docker run -d -p 5000:5000 --restart=always --name registry -v D:\registry:C:\registry stefanscherer/registry-windows:2.6.2 

    Where:
    5000:5000  is mapping your local port to the port inside container

    --name registry is setting name to "registry" of your container.

    stefanscherer/registry-windows:2.6.2 is image name(version tag is optional). As you will run Sitecore containers in Windows mode then it makes sense to run registry which is Windows container.

     D:\registry:C:\registry  is mapping your local "D:\registry" folder to folder "C:\registry" inside container. It is required to save all your work if something go wrong. All your images in your local registry will be saved on your drive, not inside the registry container. 
  2. Verify that your registry container is up and running. You can check it by opening URL: http://localhost:5000/v2/_catalog. Expected result: Empty JSON response. 
  3. Modify your build.ps1 that will be used to build Sitecore images. You need to add -Registry "localhost:5000" parameter to make sure that your images will be pushed to your local repository.
  4. Run building and pushing Sitecore images (build.ps1).  It will take sometime.
  5. Verify that you get images in your local repository. Open URL: http://localhost:5000/v2/_catalog. It should return something like this, depending on your build.ps1:
  6. Configure docker to use local registry:
  7. Now you are ready to download Sitecore images from local registry and run them in containers.