Status 400 when using a runner with Bitbucket cloud pipeline
Asked by Joe Noonan:

I am fairly new to DevOps, and have been trying to create a self hosted runner to build my projects.

I have setup a Bitbucket runner on my local machine. It uses a public docker image.

I then have a Bitbucket pipeline to use the runner, it seems to connect fine. But when it runs it gives this error:

"Status 400: {"message":"failed to create shim: OCI runtime create failed: runc create failed: unable to start container process: exec: \\"/pause\\": stat /pause: no such file or directory: unknown"}"

Any ideas on what could be the problem?


Answers:
author: Theodora Boudale
body: Hi Joe,

Could you please share the following, so we can better help you:

**1.** Are you using a runner for Linux, Windows, or MacOS?

**2.** Are the minimum requirements listed on the following page met for the machine where you set up the runner?

* <https://support.atlassian.com/bitbucket-cloud/docs/runners/>

**3.** Does this error show when you are starting the runner, or when you run a build that uses this runner?

Based on your description, it sounds like the issue occurs when you run a build, but I just want to make sure.

**4.** Does the error show in the Pipelines build log on Bitbucket website, or in the command-line application where you started the runner?

**5.** Which public docker image are you using in your build?

Kind regards,  
Theodora

comments: author: Joe Noonan
body: Hi Theodora,

1. Linux - Ubuntu 20.04.

2. Yes all minimum requirements are met. I am running Ubuntu in a VM as well.

3. The runner starts up fine and goes "online", it when I run the build.

4. In the command line where the runner is and in Bitbucket.

5. I am using a STM32 image, one I created myself but is public. (Would be great to use private images in runners though.)

The runner outputs that it executes a clone script in the clone container, then it says starting container. Which is when the error occurs. Would you like more of the runner output?

Thank you!


author: Theodora Boudale
body: Hi Joe,

Thank you for the info. Based on what you said, I suspect that the error may be related to the Docker image you are using. However, it is difficult to say for sure without seeing the Dockerfile for that image.

If you don't feel comfortable sharing the contents of the Dockerfile here, I would suggest the following troubleshooting steps:

**1.** First, try using the Docker image **atlassian/default-image:3** in your **bitbucket-pipelines.yml** (instead of your own image) for testing purposes. This is to narrow down whether the issue seems to be related to the runner or to the Docker image.

**2.** If using **atlassian/default-image:3** works, then try using the base image that you created your own image from.

If that gives the same error that you get now, the issue is most likely related to the base image.

**3.** If using the base image works ok, the next step would be to look at the Dockerfile of your custom image.

The process I would follow in this case would be to:

* take a backup of the Dockerfile
* delete all the content in the original Dockerfile and then
  * start adding one command at a time in the Dockerfile
  * build the image and push it to the registry
  * run a Runners build with that image, and see if you get the same error or not
  * repeat the process with every command you add to the Dockerfile

The purpose of this process would be to figure out what command it is that introduces this issue.

<br />

As a side note, it is possible to use private Docker images as build environments with Linux runners, you just need to provide authentication details. You can check the following documentation on how to do that:

* <https://support.atlassian.com/bitbucket-cloud/docs/use-docker-images-as-build-environments/#Using-private-build-images>

Kind regards,  
Theodora


author: Joe Noonan
body: Hi Theodora,

Thank you for your reply.

This is the contents of my dockerfile. It is in a public repo so there's no problem sharing it here.

FROM ubuntu:latest

# Download Linux support tools  
RUN apt-get update \&\& \\  
apt-get clean \&\& \\  
apt-get install -y \\  
build-essential \\  
wget \\  
curl \\  
git  

# Adds the STM32CubeIDE folder into the image in /opt/st/.  
ADD stm32cubeide_1.9.0/ /opt/st/

# Add to the PATH variable so the stm32cubeide executable can be called anywhere  
ENV PATH $PATH:/opt/st/

I will try these steps as well to try eliminate the issue anyway.

Also I am using the command when creating the Bitbucket runner, the same as this - [Custom docker image with Bitbucket runners.](https://support.atlassian.com/bitbucket-cloud/docs/use-your-docker-images-in-self-hosted-runners/)

With the PAUSE_IMAGE, CLONE_IMAGE and AUTH_PROXY_IMAGE as my own custom public image.

Sorry I meant it would be nice to use a private docker image in the runner command, it only allows public images at the moment.

In my bitbucket-pipelines.yml file I only need to specify the runner and not include the docker image there as well as in the runner command?

Thanks,

Joe.


author: Joe Noonan
body: I just tried putting my custom image back in my bitbucket-pipelines.yml file and removed it from the bitbucket runner command... and it finally worked!

I'm guessing the pipeline tells the runner that it is using a specific image and then the runner pulls that image down?

This link seemingly is confusing, as my take on it was I had to specify the custom docker image as a argument. But clearly that is not the case. Maybe this needs clearing up more?

<https://support.atlassian.com/bitbucket-cloud/docs/use-your-docker-images-in-self-hosted-runners/>

Thanks,

Joe


author: Theodora Boudale
body: Hi Joe,

Thank you for your reply and the additional info.

I think I may have misunderstood the issue. Just to give you some context:

Apart from the Docker container that runs for the runner, each step of your build is also executed in another Docker container.  
E.g. if I have a yml file like the following:

```
image: atlassian/default-image:3

pipelines:
  branches:
    testing-branch:
      - step:
          runs-on: 
            - 'self.hosted'
            - 'linux'
          script:
            - echo "Hello"
```

Then my builds will run in another Docker container using the image **atlassian/default-image:3** (which will get destroyed once the step finishes).

Just to make sure we're on the same page regarding the problem:

Are you using your custom image in your bitbucket-pipelines.yml file?  
Or only to override the image of the runner mentioned here?

<https://support.atlassian.com/bitbucket-cloud/docs/use-your-docker-images-in-self-hosted-runners/>

Kind regards,  
Theodora


author: Joe Noonan
body: Hi Theodora,

No worries I'm new to all of this so I may not understand exactly what is happening!

So I was originally using a custom image in the bitbucket-pipelines.yml file but then I was trying to use a runner on my local machine. So I was looking at the same link you posted, and thought that I no longer needed to use a custom image in the bitbucket-pipelines.yml file. And instead add the arguments to the runner command. But that's what was giving me the original problem. The link was just confusing me, not sure when I would need to specify a custom image in the runner command.

But to get it to work, I went back to using a custom image in the bitbucket-pipelines.yml file and I now use the default command Bitbucket gives me when I create a runner.

I'm probably wrong but is that because the pipeline is basically run in the runner, and it pulls the custom image I specify in the bitbucket-pipelines.yml file somehow?


author: Theodora Boudale
body: Hi Joe,

Pipelines builds that run in our own infrastructure, and also Pipelines builds that run in Linux runners, they both run in Docker containers.

For every step of the bitbucket-pipelines.yml, a Docker container starts, the commands of that step's script are executed, and then the container gets destroyed.

The Docker image that is used for the build container is the one specified in the bitbucket-pipelines.yml file. If no image is specified in that file, then the image [atlassian/default-image:latest](https://hub.docker.com/r/atlassian/default-image/) will be used. This is the case both for builds than run in our own infrastructure and also for builds that run in Linux Runners.

When using Linux Runners, the builds do not run in the container of the Runner, but a different container starts for each step of your build (using the image you specified in bitbucket-pipelines.yml).

<br />

If your goal is to use your custom Docker image as a build environment where your builds run, you need to specify this in the bitbucket-pipelines.yml file.

You can specify this globally (see the example bitbucket-pipelines.yml file in my previous reply), but you can also specify a different image for each step, as below:

```
pipelines:
  branches:
    testing-branch:
      - step:
          runs-on: 
            - 'self.hosted'
            - 'linux'
          image: ubuntu:latest
          script:
            - echo "Hello"
      - step:
          runs-on: 
            - 'self.hosted'
            - 'linux'
          image: openjdk
          script:
            - echo "Hello"
```

Kind regards,  
Theodora


author: Joe Noonan
body: Hi Theodora,

Thank you for your reply, it was very useful and confirms what I was thinking. I understand how the images are used and where they are used. My pipeline is now running and building successfully!

Thank you!


author: Theodora Boudale
body: You are very welcome Joe, I'm glad to have helped!

Please feel free to reach out if you ever need anything else!

Kind regards,  
Theodora


Tags: bitbucket-cloud

bitbucket-runners

cloud

linux