Skip to main content

Container API reference

概要

The container configuration for both Step execution containers and service containers allows multiple options in addition to the image name and version.

Beta feature

This feature is in beta and we do not recommend using it with production applications. Register here for the beta.

You can define a Step execution container and a service container for a group of Steps. For a Step execution container, each Step within a with group will be running in the defined container.

The container configuration for both Step execution containers and service containers allows multiple options in addition to the image name and version.

Accessing services

Service containers can be used even when the Step group is not using a Step execution container. The only difference is how to access the services.

Use the <service_id> (name of the service) to access it when you are using Step execution container. For example, http://postgres:5432.

Use localhost to access your service if you are not using a Step execution container. For example, http://localhost:5432.

表1 Step execution container and service API reference

Name

Description

workflows.<workflow_id>.container.image

workflows.<workflow_id>.services.<service_id>.container.image

The docker image to use for a Step execution container or a service container in [REPOSITORY[:TAG]] format.

containers:
  my-container:
    image: us.gcr.io/my-project/my-image:v2containers:

workflows.<workflow_id>.container.credentials.*

workflows.<service_id>.container.credentials.*

The credentials allow you to control the parameters supplied for the docker login command. Check your registries documentation on how to use docker login.

containers:
  my-container:
    image: us.gcr.io/my-project/my-image:v2
    credentials:
      username: _json_key_base64
      password: $GCP_SERVICE_ACCOUNT
      # Server is optional if already part of the image
      server: us-central1-docker.pkg.dev

workflows.<workflow_id>.container.credentials.username

workflows.<workflow_id>.services.<service_id>.container.credentials.username

The username that will be used with the docker login command.

workflows.<workflow_id>.container.credentials.password

workflows.<workflow_id>.services.<service_id>.container.credentials.password

The password that will be used with the docker login command.

Use a secret

You can reference a Bitrise Secret to avoid exposing your password in the bitrise.yml file.

workflows.<workflow_id>.container.credentials.server

workflows.<workflow_id>.services.<service_id>.container.credentials.server

The server for the docker login command. This is optional if the server is already part of the image reference.

workflows.<workflow_id>.container.ports

workflows.<workflow_id>.services.<service_id>.container.ports

An array of port mappings that will be be exposed on the host in the format of [HostPort]:[ContainerPort].

containers:
  my-container:
    image: python:3.8
    ports:
    - "3000:3000"

workflows.<workflow_id>.container.envs

workflows.<workflow_id>.services.<service_id>.container.envs

List of Environment Variables.  Each individual variable must be in its own single length array.

Using the env property

Using the Workflow level env property will also work: containers inherit those, too.

containers:
  my-container:
    image: python:3.8
    envs:
    - MY_VAR: my_value
    - ANOTHER_VAR: another_value

workflows.<workflow_id>.container.options

workflows.<workflow_id>.services.<service_id>.container.options

Used to configure additional Docker container resource options (parameters that will be passed to the docker create command).

Not supported options

--network, --volume (-v), and --entrypoint are not supported.