Add a Docker Image Service

Updated 6 days ago by Michael Cretzman

This guide describes how to add a Docker Image service in a Harness application. For details on different using Docker with Kubernetes and Helm, see Docker, Kubernetes, and Helm Deployment and Kubernetes and Harness FAQ.

Intended Audience

  • DevOps

Before You Begin

Add a Docker Image Service

A Docker Image service can use a number of different artifact sources for its images. You can specify container commands for the artifact, enter configuration variables and files, and use ConfigMap and Helm Value YAML.

To specify an artifact source for your Docker image service, do the following:

  1. In the Service Overview, click Add Artifact Source and select the type of artifact source for your service. The Artifact Source dialog appears with settings specific to the artifact source type you selected. For instructions on the artifact source you selected, see below.
Docker Registry Artifact Source

The Docker Registry Artifact Source has the following fields.

Field

Description

Name

You can enter a name of have Harness generate one for you automatically.

Source Server

In Source Server, select the name of the artifact source server you added in Add an Artifact Server.

Docker Image Name

Click in Docker Image Name and select or enter the name of the artifact you want to deploy, such as library/tomcat. By default, Harness automatically populates the field with the artifacts available from the source server, but some artifact servers do not allow anyone to scan its artifacts.

If you click Artifact History you will see the build history that Harness pulled from the source server.

ECR Artifact Source

The ECR Artifact Source has the following fields.

Field

Description

Name

You can enter a name of have Harness generate one for you automatically.

Cloud Provider

Select the name of the artifact source server you added in Cloud Providers.

Region

Select the region where the artifact source is located.

Docker Image Name

Click in Docker Image Name and select or enter the name of the artifact you want to deploy. By default, Harness automatically populates the field with the artifacts available from the ECR source server.

If you click Artifact History you will see the build history that Harness pulled from the source server.

Azure Container Registry Artifact Source

The Azure Container Registry Artifact Source has the following fields.

Field

Description

Name

You can enter a name of have Harness generate one for you automatically.

Cloud Provider

Select the name of the artifact source server you added in Cloud Providers.

Subscription

Harness will automatically pull the available GUIDs. Select an Azure Subscription GUID.

Azure Registry Name

Harness will automatically pull the available names. Select a name.

Repository Name

Harness will automatically pull the available repository names. Select a name.

If you click Artifact History you will see the build history that Harness pulled from the source server.

GCR Artifact Source

The Google Cloud Container Registry (GCR) Artifact Source has the following fields.

Field

Description

Name

You can enter a name of have Harness generate one for you automatically.

Cloud Provider

Select the name of the artifact source server you added in Cloud Providers.

Registry Host Name

Once you select a cloud provider, the list of registries is populated automatically. Select the registry where the artifact source is located.

Docker Image Name

Click in Docker Image Name and select or enter the name of the artifact you want to deploy. By default, Harness automatically populates the field with the artifacts available from the GCR source server.

If you click Artifact History you will see the build history that Harness pulled from the source server.

Artifactory Artifact Source

The ECR Artifact Source has the following fields.

Field

Description

Name

You can enter a name of have Harness generate one for you automatically.

Source Server

Select the name of the artifact source server you added in Cloud Providers. The format for the cloud-based Artifactory URL is https://company_name.jfrog.io/context. For more information, see Pushing and Pulling Images from JFrog.

Repository

Select the repository where the artifact source is located.

Docker Image Name

Click in Docker Image Name and select or enter the name of the artifact you want to deploy. By default, Harness automatically populates the field with the artifacts available from the ECR source server.

Docker Repository Server

Enter the URL of the remote Docker repository server if needed. See Configuring Docker Repositories from JFrog for more information.

If you click Artifact History you will see the build history that Harness pulled from the source server.

Nexus Artifact Source

The Nexus Artifact Source has the following fields.

Field

Description

Name

You can enter a name of have Harness generate one for you automatically.

Source Server

Select the name of the artifact source server you added in Cloud Providers.

Repository

Select the name of the repository where the artifact is located.

Docker Image Name

Click in Docker Image Name and select or enter the name of the artifact you want to deploy. By default, Harness automatically populates the field with the artifacts available from the ECR source server.

Docker Port

Enter the port number to pull from the Docker repo. Typically, 8083. For more information, see Using Nexus 3 as Your Repository – Part 3: Docker Images from Sonatype.

If you click Artifact History you will see the build history that Harness pulled from the source server.

Container Specs

You can use container and chart specifications to configure a Docker Image service. Specifications can send initialization commands when triggering a new container, specify the required CPU and memory for the container, and more.

ECS Container Spec

For details on ECS Container and Service Specification settings, see AWS Elastic Container Service (ECS) Deployment.

Kubernetes Container Spec

For information about the Kubernetes Container Specification, see Docker, Kubernetes, and Helm Deployment and Kubernetes and Harness FAQ.

Helm Chart Spec

For information about the Helm Chart Spec, see Docker, Kubernetes, and Helm Deployment. For information on Helm Charts, see The Chart Repository Guide from Helm.

Scripts

The Scripts Specifications section has options and templates for you to add Bash and PowerShell scripts for use in the deployment of this service.

Use the Template Library

The Template Library has a wealth of scripts you can use to rapidly develop your script.

  1. In the Script section of Deployment Specification, click Add Command. The Add Command dialog appears.
  2. Click From Template Library. The Template Library is displayed. Find the template you need.
  3. Click Link or click the drop-down menu and choose Copy. You can link to a templates or copy a template to your service. If you link to the template, when that version of the template is updated in the Template Library, your script is also updated. If you copy a template, there is no link to the Template Library. If you link to a template, you may only edit the template from the template dialog. You cannot edit the template in your service.
  4. Edit the script if needed and click SUBMIT. The script is added to your service.
    Every time you edit a template, you create a new version of it. To switch versions, click the three dots on the script title bar and choose Manage Versions.
  5. To edit the variables used in the script, click Variables. The Edit Command dialog opens. Edit the variables and click SUBMIT.

Create a New Command

  1. In the Script section of Deployment Specification, click Add Command. The Add Command dialog appears.
  2. Click Create New.
  3. In Name, enter a name for the new command that describes its function.
  4. From Command Type, select the function of the command, such as Start, Install, Disable, etc.
  5. Click Submit. The new command is added under Script.
  6. Mouseover the Add button to see the available commands.
  7. Click a command from the list. The dialog for the command appears. For example, here is the dialog for the Docker Start command.
    The dialog contains a default script relating to it type. The script is prefigured for variables for common application information.
  8. From Script Type, select BASH or POWERSHELL.
  9. Modify the script is needed and click SUBMIT. The command is added to the Script section:
  10. Click the command icon to see or modify the script.
  11. Mouseover the command icon to see a plus icon. Mouseover the icon to see the command list and select another command for your script.

Configuration Variables and Files

For information about how configuration variables and files are used in a Kubernetes deployment, see Kubernetes and Harness FAQ. For information on using Harness variables and expressions, see Variables and Expressions in Harness.

Config Variables

You can create service-level variables to use throughout your service configuration settings.

To use service-level variables, do the following:

  1. In Configuration, in Config Variables, click Add Variable. The Config Variable dialog appears.
  2. In Name, enter a name for your variable. This is the name you will use to reference your variable anywhere in your service.
  3. In Type, select Text or Encrypted Text.

    If you selected Text, enter a string in Value.

    If you select Encrypted Text, the Value field becomes a drop-down and you can select any of the Encrypted Text you have configured in Secrets Management. For more information, see Secret Management. You can also click Add New Encrypted Text to create a new secret.

    You can also use Harness variables in the Value field. To use a variable, enter $ and see the available variables.



    For example, to add workflow variables, enter ${workflow and the available workflow variables are displayed. For more information about variables, see Variables and Expressions in Harness.
  4. Click SUBMIT. The variable is added to Config Variables.
  5. To reference the variable is any text field in your service configuration, type $ and Harness will provide a drop down of all variables. Begin typing the name of your variable to find it and select it.

ConfigMap YAML

For information about how the ConfigMap is used in a Kubernetes deployment, see Docker, Kubernetes, and Helm Deployment and Kubernetes and Harness FAQ.

Helm Values YAML

For information on Helm Values YAML, see Docker, Kubernetes, and Helm Deployment.


How did we do?