Docker HowTo
Docker HowTo
Table of content
              Table of content
                   Purpose
                   1. Tools
                       1.1 Docker
                              1.1.1 Runners
                       1.2 JFrog Artifactory
                              1.2.1 Repositories (Storage)
                   2. Docker image version strategy
                       2.1 Image naming strategy
                              Base image
                              Project image
                       2.2 Tag Versioning
                       2.3 Tag strategy example
                              Conclusion
                   3. Manage dockerfiles and images
                       3.1 Resources
                              3.1.1 GitLab repository for dockerfiles
                       3.1.2 Storing docker files in the repository
                              3.1.3 JFrog Artifactory for docker images
                              3.1.4 JFrog Artifactory for software
                   4. Use Cases
                       4.1 Add new base image
                              4.1.1 Windows
                       4.2 Create new docker image from existing base image
                              4.2.1 Windows
                       4.3 Update existing docker image
                              4.3.1 Windows
                       4.4 Update Operating System in the docker image
                              4.4.1 Windows
                       4.5 Update docker image with Subcommands (Linux)
                              4.5.1 Windows
                              4.5.2 Linux
                       4.6 Update software version in docker image
                       4.7 Get container Operating System version
                              4.7.1 Windows
                       4.8 Upload software to the Artifactory
                              Useful links
          Purpose
          The purpose of this document is to describe the docker strategy and processes related to creating, storing, and versioning docker images.
          1. Tools
          GitLab CI Components
          1.1 Docker
          Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are
          isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined
          channels.
          A Docker image is a file used to execute code in a Docker container. Docker images act as a set of instructions to build a Docker container, like a
          template. Docker images also act as the starting point when using Docker. An image is comparable to a snapshot in virtual machine (VM)
          environments.
          Docker is used to create, run and deploy applications in containers. A Docker image contains application code, libraries, tools, dependencies and other
          files needed to make an application run.
1 of 16                                                                                                                                                                   2023-04-25, 17:43
Firefox                                                                                     https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
1.1.1 Runners
          We have two types of operating system that can run docker containers inside Medtronic network as a part of GitLab project CI/CD - Windows and
          Linux.
          The first one diabetes_software-generic-shared-local (Package Type: Generic) - is for storing software that is used for Docker image creation. It is a
          public read-only repository. The main idea for this repository is to avoid any external downloads from the internet. All software that is used in CI/CD
          should be stored inside the Medtronic infrastructure.
          The second repository diabetes_software-docker-shared-local (Package Type: Docker) - is for storing Docker images that are used in projects CI/CD
          (repository pipelines).
Base image
          A base image is the image that is used to create all of your container images. Your base image can be an official Docker image, such as Centos, or you
          can modify an official Docker image to suit your needs, or you can create your own base image from scratch.
2 of 16                                                                                                                                                                      2023-04-25, 17:43
Firefox                                                                                https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
          {tag} - tag version of the base image should contain the exact operating system version.
          Example (Windows): 10.0.17763.2300
          NOTE: tag name contains the full operating system version, so there is no need to create the intermediate folder with the patch version in the image
          name.
Project image
          {OS-version-short} - operating system major version (or major and minor version).
          Example (Windows): 2019
          Example (Linux Ubuntu): 20.04
          {component-name} - main software component in the docker image (software name that is installed in the image. Typically the compiler name)
          Example: iar , ms-buildtools
          {tag} - tag version of the docker image in accordance to the Tag Versioning section.
          Example: 1.0
3 of 16                                                                                                                                                                 2023-04-25, 17:43
Firefox                                                                                    https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
Example: case.artifacts.medtronic.com
          {OS-version-short} - operating system major version (or major and minor version).
          Example (Windows): 2019
          Example (Linux Ubuntu): 20.04
          {first-component-name} - main software component in the docker image (software name that is installed in the image. Typically the compiler name).
          Example: iar , ms-buildtools
          {second-component-name} - a second software component that is used with the first component.
          Example: coverity , bullseye
          {tag} - tag version of the docker image in accordance to the Tag Versioning section.
          Example: 1.0
          Major Version
          The Major software number is denoted by an integer. This number is incremented when the following modifications have been made:
When the Major version is incremented, the Minor version must be reset to 0.
          Minor Version
          The Minor software number is denoted by an integer. This number is incremented when the following modifications have been made:
          All initial Docker images should have the following tags: :1.0 , :1 , latest .
          For better understanding please see the Tag strategy example section.
4 of 16                                                                                                                                                                     2023-04-25, 17:43
Firefox                                                                              https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
          During development, the team has observed incorrect behavior during compilation. The development team has requested an update.
          The DevOps team has found a bug in the script. So they have made a fix and updates to the docker image.
          The Minor version has been incremented.
          The image name remains the same.
          All tags were added to the new image (please see case 2 image below)
We can see that two tags were overwritten with the new image and now they are pointing to the most recent docker image.
          There was a request from the development team to update the existing image with a new component.
          DevOps team has installed the required components in the docker image and incremented the Major version.
          The image was pushed to the Artifactory with three tags.
          The image name remains the same.
This time only one tag was overwritten. Let's see the image below.
5 of 16                                                                                                                                                               2023-04-25, 17:43
Firefox                                                                                 https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
          In the next request, some additional Python packages were installed. Docker image and tags were updated accordingly.
          Please see image case 4 below.
          The development team asked to expose some ports in the docker image. The Minor version has been incremented.
          Please see image case 5 below.
          In the example below, the docker base image (the operating system) was updated with a newer version.
          This update will affect the image name, that means that image will have new location in the Artifactory.
          Initial project image with tree tags was created accordingly.
          Please see image case 6 below.
6 of 16                                                                                                                                                                  2023-04-25, 17:43
Firefox                                                                                 https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
Conclusion
           1. <major>.<minor> - this tag will not be overwritten. This tag will always point to the same image even if a newer version exists.
           2. <major> - this tag will point to the image that will always contain the latest fixes for the same OS, Software and library/package versions.
           3. <latest> - this tag will contain the most recent updates to the image in the scope of the fixed version of compiler/framework/tool.
3.1 Resources
In the repository /dockerfiles/readme.md file stored all information regarding docker images in the following format.
                                                     case.artifacts.medtronic.com/diabetes_software-
                                                     docker-shared-local/diabetes-software/devops                                  mcr.microsoft.com/windows
            No Dockerfile (Base Image)                                                                     10.0.17763.2300
                                                     /base-images/windows                                                          /servercore:10.0.17763.2300
                                                     /2019/servercore:10.0.17763.2300
                                                     case.artifacts.medtronic.com/diabetes_software-                               case.artifacts.medtronic.com/diabetes_software-
            dockerfiles/windows
                                                     docker-shared-local/diabetes-software/devops                                  docker-shared-local/diabetes-software/devops
            /2019/10.0.17763.2300/iar/9.10.2                                                               1.0
                                                     /project-images/windows                                                       /base-images/windows/2019/10.0.17763.2300
            /Dockerfile.iar-9.10.2-1.0
                                                     /2019/10.0.17763.2300/iar/9.10.2:1.0                                          /tools/python-git:1.0
                                                     case.artifacts.medtronic.com/diabetes_software-
            dockerfiles/windows                                                                                                    case.artifacts.medtronic.com/diabetes_software-
                                                     docker-shared-local/diabetes-software/devops
            /2019/10.0.17763.2300/iar/9.10.2                                                                                       docker-shared-local/diabetes-software/devops
                                                     /project-images/windows                               1.0
            /coverity/2021.12.0                                                                                                    /project-images/windows
                                                     /2019/10.0.17763.2300/iar/9.10.2/coverity
            /Dockerfile.coverity-2021.12.0-1.0                                                                                     /2019/10.0.17763.2300/iar/9.10.2:1.0
                                                     /2021.12.0:1.0
7 of 16                                                                                                                                                                  2023-04-25, 17:43
Firefox                                                                                    https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
                                                      case.artifacts.medtronic.com/diabetes_software-
            dockerfiles/windows                                                                                                       case.artifacts.medtronic.com/diabetes_software-
                                                      docker-shared-local/diabetes-software/devops
            /2019/10.0.17763.2300/ms-                                                                                                 docker-shared-local/diabetes-software/devops
                                                      /project-images/windows                                 1.0
            buildtools/16.11/bullseye/8.25.7                                                                                          /project-images/windows
                                                      /2019/10.0.17763.2300/ms-buildtools/16.11
            /Dockerfile.bullseye-8.25.7-1.0                                                                                           /2019/10.0.17763.2300/ms-buildtools/16.11:1.0
                                                      /bullseye/8.25.7:1.0
          Microsoft servercore:
          https://hub.docker.com/_/microsoft-windows-servercore
          Microsoft nanoserver:
          https://hub.docker.com/_/microsoft-windows-nanoserver
          Ubuntu:
          https://hub.docker.com/_/ubuntu?tab=tags
For better traceability it is recommended to keep folder structure similar to JFrog Artifactory structure.
NOTE: Dockerfile location should be very similar to the Artifactory location for better traceability.
          {component-name} - main software component in the docker image (software name that is installed in the image. Typically the compiler name)
          Example: iar , ms-buildtools
          {software-info} - the custom name that will help the user to identify Dockerfile usage. If this image is "project-specific", then Dockerfile could contain
          the repository name.
Example of full path to the dockerfile (from the repository root location)
./dockerfiles/windows/2019/10.0.17763.2300/iar/9.10.2/Dockerfile.iar-9.10.2-1.0
All Diabetes Software project docker images will be stored under diabetes_software-docker-shared-local location.
          Artifactory URL:
          https://case.artifacts.medtronic.com/
          Artifactory common folder for docker base images (Windows and Linux):
          https://case.artifacts.medtronic.com:443/artifactory/diabetes_software-docker-shared-local/diabetes-software/devops/base-images/windows/
8 of 16                                                                                                                                                                     2023-04-25, 17:43
Firefox                                                                                  https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
https://case.artifacts.medtronic.com:443/artifactory/diabetes_software-docker-shared-local/diabetes-software/devops/base-images/linux/
All software that is used in the docker images will be stored under diabetes_software-generic-shared-local location.
          Artifactory URL:
          https://case.artifacts.medtronic.com/
Keep the software installer location with the version and name.
4. Use Cases
4.1.1 Windows
          The base image - is the officially released Docker image by the distributor. Initial Docker image pulled from official sources and saved in the
          Artifactory without any modifications.
          IMPORTANT: Windows requires the host OS version to match the container OS version. If you want to run a container based on a newer Windows
          build, make sure you have an equivalent host build.
9 of 16                                                                                                                                                                   2023-04-25, 17:43
Firefox                                                                                https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
Example:
5. Update the TAG for Docker image in accordance to naming strategy described in section 2.1.
Example:
docker image ls
               Where:
               [user_id] - Medtronic user ID (login)
               [remote_repository_url] - JFrog Artifactory URL Example:
Example:
               Where:
               [remote_repository_url] - JFrog Artifactory URL Example:
10. Update /dockerfiles/readme.md table in the devops-build-scripts repository with new image information.
14. After the merge request has been reviewed branch should be merged.
4.2.1 Windows
           IMPORTANT: Windows requires the host OS version to match the container OS version. If you want to run a container based on a newer Windows
           build, make sure you have an equivalent host build.
           Before starting image creation you should have compleate list of required tools and dependencies.
           All software should be uploaded to the Artifactory repository diabetes_software-generic-shared-local . check section 3.1.4
10 of 16                                                                                                                                                                2023-04-25, 17:43
Firefox                                                                                  https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
3. Create Dockerfile in appropriate location with well informative naming (TAG - section 2.2, Dockerfile naming - section 3.1.2).
FROM {[image-name]:[TAG]}
Example:
FROM case.artifacts.medtronic.com/diabetes_software-docker-shared-local/diabetes-software/devops/base-images/windows/2019/servercore:10.0.1
6. Open powershell terminal with administrator privileges and navigate to the directory with the newly created dockerfile .
7. Build docker image from Dockerfile with tag version format {major}.{minor} .
Example:
docker image ls
Example:
docker image ls
11 of 16                                                                                                                                                                  2023-04-25, 17:43
Firefox                                                                                 https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
               Where:
               [user_id] - Medtronic user ID (login)
               [remote_repository_url] - JFrog Artifactory URL Example:
Example:
               Where:
               [remote_repository_url] - JFrog Artifactory URL Example:
15. Add updated registry table and new dockerfile to the devops-build-scripts repository.
18. After the merge request has been reviewed branch should be merged.
4.3.1 Windows
            3. Create Dockerfile in appropriate location with well informative naming (TAG - section 2.2, Dockerfile naming - section 3.1.2).
               NOTE: If change does not affect the main components of the docker image, create a new dockerfile on the same level as the previous one and
               then update the tag version accordingly.
4. Define the Base image in Dockerfile (use the most recent one, where the change should be added).
FROM {[image-name]:[TAG]}
Example:
FROM case.artifacts.medtronic.com/diabetes_software-docker-shared-local/diabetes-software/devops/project-images/windows/2019/10.0.17763.230
6. Open powershell terminal with administrator privileges and navigate to the directory with the newly created dockerfile .
7. Build docker image from Dockerfile with a new tag version {major}.{minor} .
Example:
12 of 16                                                                                                                                                                 2023-04-25, 17:43
Firefox                                                                                https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
Example:
docker image ls
               Where:
               [user_id] - Medtronic user ID (login)
               [remote_repository_url] - JFrog Artifactory URL Example:
Example:
               Where:
               [remote_repository_url] - JFrog Artifactory URL Example:
15. Add updated registry table and new dockerfile to the devops-build-scripts repository.
18. After the merge request has been reviewed branch should be merged.
4.4.1 Windows
13 of 16                                                                                                                                                                2023-04-25, 17:43
Firefox                                                                                  https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
3. Create Dockerfile in appropriate location with well informative naming (TAG - section 2.2, Dockerfile naming - section 3.1.2).
            4. If you need to upgrade the operating system for a Docker image that has multiple versions, then you need to combine all the Dockerfiles into the
               new one (deleting repetitive instructional steps but keeping the correct order).
5. In the line where base image is defined FROM , replace old base image URL with new base image URL.
7. Open powershell terminal with administrator privileges and navigate to the directory with the newly created dockerfile .
            8. Build docker image from Dockerfile with a new tag version {major}.{minor} .
               NOTE: Since you are updating the Operating System version, and this is affecting the Dockerfile and Artifactory image location, the Dockerfile tag
               most likely will start with version 1.0.
docker image ls
docker image ls
16. Add updated registry table and new dockerfile to the devops-build-scripts repository.
19. After the merge request has been reviewed branch should be merged.
4.5.1 Windows
TODO
4.5.2 Linux
TODO
14 of 16                                                                                                                                                                  2023-04-25, 17:43
Firefox                                                                                    https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
4.7.1 Windows
           IMPORTANT: Windows requires the host OS version to match the container OS version. If you want to run a container based on a newer Windows
           build, make sure you have an equivalent host build.
1. Open powershell terminal with administrator privileges and navigate to the directory with the newly created dockerfile .
               Where:
               [user_id] - Medtronic user ID (login)
               [remote_repository_url] - JFrog Artifactory URL Example:
Example:
Example:
Useful links
15 of 16                                                                                                                                                                    2023-04-25, 17:43
Firefox                                                                               https://code.medtronic.com/diabetes-software/devops/devops-documentation/-/blob/develop/instructi...
16 of 16 2023-04-25, 17:43