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

Self hosted runner: Execute command from Bitbucket runner to another container

nioanto November 25, 2021

Hi to all,

on my personal host I have a 3 container:

  •  .Bitbucker runner
  • . debian with dpkg-buildpackage script
  • . apache web server

When I login inside Bitbucket runner container, from inside  I can do it  "docker ps ",    the output is that:

output.PNG

from Bitbucker runner container I can do  docker ps;  "docker exec -it container_name foo_bar" and/or "docker run"

but

When I run my pipeline:



image
: atlassian/default-image:3 options: docker: true pipelines: default: - step: name: 'execute command from external container' script: - docker exec -itu infallible_vaughan any_command_you_want

 

I retrive this error:

Error: No such container:

 

someone can help me to use the container that are running on my server from Bitbucket pipeline?

 

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 30, 2021

Hi @nioanto,

In order to provide isolation and reproducibility, a runner doesn’t provide access directly to the host file system, so it is not possible to access any Docker containers that are running on the host machine during a Pipelines (runner) build.

You could run a docker container during the build with a docker run command in your yml file and it should then be possible to execute docker commands in that container with docker exec, but without the -it options, as they aren't supported in Pipelines.

Also, just a heads up, you need to add a runs-on parameter to a step in the bitbucket.pipelines.yml file with at least the self-hosted label, in order for the build to run on your runner:

I'm not sure if you have that already in the yml file of your repo and removed it when you copied and pasted the contents of the yml file here, I just mention it in case it's missing.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events