Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to dynamically specify a docker image to load as a service

Jonas De Beukelaer February 14, 2019

Hey!

I'm trying to use a docker image, built in step 1, as a service in step 2.

The docker image name is defined by the short commit sha, so the docker image url has to be dynamically set.

Is there any way to do this?

Or would I have to define a static image name (e.g. :testing) to use specifically for this pipeline?

pipelines:
  branches:
    master:
      - step:
          image: go:something
          script:
            - # test go code
            - # build docker image with tag=short_commit_sha (7chars)
      - step:
          image: acceptance_tester_image
          script:
            - # test api server image using service api-server
          services:
            - api-server
definitions:
  services:
    api-server:
      image:
        name: IMAGE/I/BUILT/IN/STEP/ONE:short_commit_sha
options:
  docker: true

 

2 answers

1 accepted

1 vote
Answer accepted
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2019

This feature is currently not supported in Pipelines. There's an open feature request for adding support for environment variables in Docker image names that you can follow if you're interested.

Using Docker Compose is the way to go here! It's an intentional use-case we had for providing Docker in Docker.

The associated issues with Docker in Docker are ones that the Pipelines team has to stay on top of. They (mostly) won't affect you when using Docker inside of Pipelines. So feel free to use Docker as much as you'd like.

Jonas De Beukelaer March 5, 2019

Hey Philip, thanks for the details. Good to get confirmation that our current setup should be fine to stick with :)

I'll follow that feature request for now.

Like Philip Hodder likes this
0 votes
Edwin Kyalangalilwa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 3, 2019

Hi @Jonas De Beukelaer ,

Please look into utilizing variables.

Variables in pipelines - especially the default variables.

Jonas De Beukelaer March 4, 2019

Thanks for your answer Edwin.

Unfortunately Pipelines doesn't seem to allow for substituting variables in the image name of a service (even when the image name is surrounded with double quotes)

For now I'm using docker-compose within a step. It's not ideal, and I know some people advise against docker-in-docker, but it seems to be working well for now. This also remove side-effects from having an image uploaded to our registry for testing purposes.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events