Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I pass an argument to a service container in a bitbucket pipeline?

mac_nsr March 30, 2022

I am trying to set up a bitbucket pipeline that uses a database service provided by a container. However, in order to get the database service started correctly, I need to pass an argument to be received by the database container's ENTRYPOINT. I see from the pipeline service doc that it's possible to send `variables` to the service's docker container, but the option I need to set isn't settable by an environment variable, only by a command line argument.

When I run the database's docker image locally using `docker run`, I am able to set the option just by adding it to the end of the `docker run` command, and it gets correctly applied to the container's ENTRYPOINT, so it seems like it should be straightforward, I just can't figure out where to put the argument in bitbucket-pipelines.yml.

So, for example, here's a sample `definitions` section showing what I'm looking for:

definitions:
services:
myFavoriteDatabase:
image: myFavoriteDatabase
something-here-to-pass-an-argument-to-myFavoriteDatabase-please: "-myOption 10"

2 answers

1 accepted

0 votes
Answer accepted
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 31, 2022

Hi @mac_nsr

Welcome to the community.

Unfortunately, it's not possible to pass extra arguments or commands while running a service container on Pipelines.

As a workaround, you have 2 options for this:

  1. You can start the service container by running a Docker command within Pipelines as long as the command is not restricted.
    • You can check this link for more information about Docker restricted commands on Pipelines.
  2. You can create your own Docker image (using Dockerfile) and upload it to Docker Hub then use that image as a service container on Pipelines

Hope it helps and let me know if you have further questions that I can help with.

Regards,
Mark C

mac_nsr April 1, 2022

Thanks @Mark C, I imagine I can make one of those workarounds work. In the meantime, is there a way to turn this into a feature request? I imagine I'm not the only one who would find it convenient to be able to pass arguments to a service container, and it seems pretty similar to the `variables` feature that's already available.

0 votes
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 4, 2022

Hi @mac_nsr,

I went ahead and created a feature request for you that can be located through this link. - https://jira.atlassian.com/browse/BCLOUD-21810
You can upvote and watch it for now so that you'll be notified of any updates from our team when the feature becomes available on Bitbucket Cloud.

Please do note that we don't have an exact ETA for the feature request as all new features will be implemented according to our policy here.

Hope it helps and let me know if you have further questions.

Regards,
Mark C

mac_nsr April 4, 2022

Thank you, I appreciate you adding the feature request.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events