Selfhosted runner, cannot use docker commands.
Asked by Kristian Overgaard:

I've run into a problem where a selfhosted runner, no longer works with docker commands.

I'm using a Linux runner, and adds docker with the services: docker in the bitbucket pipelines yml.

It worked back in version 1.364  

Runner matching labels:  
- linux  
- self.hosted  
Runner name: Stat Migration Runner  
Runner labels: statapi, self.hosted, linux  
Runner version:  
current: 1.364  
latest: 1.364  
where it uses a build and docker image:  
Images used:  
build: atlassian/default-image@sha256:5ce8190e86ba11a8e935735ad2059524b020a0a6f652ff4df614353329af0c07  
docker: [docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-docker-daemon@sha256:10c58123e749b96c7a8b00d5a93e5d47b66d487c6595d02723bf3f14e23e1b78](http://docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-docker-daemon@sha256:10c58123e749b96c7a8b00d5a93e5d47b66d487c6595d02723bf3f14e23e1b78)  
On the newest version 1.371 it doesn't use the docker image:  

Runner matching labels:  
- linux  
- self.hosted  
Runner name: Stat Migration Runner  
Runner labels: statapi, self.hosted, linux  
Runner version:  
current: 1.371  
latest: 1.371  

<br />

Images used:  
build: atlassian/default-image@sha256:5ce8190e86ba11a8e935735ad2059524b020a0a6f652ff4df614353329af0c07  
docker: [docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-docker-daemon@sha256:40063c931c8ba57e7f2e00f8134748ff45424f4310e91a6c7179c0d13a608247](http://docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-docker-daemon@sha256:40063c931c8ba57e7f2e00f8134748ff45424f4310e91a6c7179c0d13a608247)
extract from pipelines yml: (apologies for formatting, not sure how to add code blocks or no-format blocks. )  
pipelines:  
branches:  
'master':  
- step:  
name: 'Build and push'  
script:  
- docker version  
services:  
- docker  
- step:  
name: 'Database Migration'  
runs-on:  
- self.hosted  
- linux  
script:  
- docker version  
services:  
- docker  
I've also asked about this on stackoverflow <https://stackoverflow.com/questions/74374301/docker-in-docker-doesnt-work-on-self-hosted-linux-runner>


Answers:
author: Mark C
body: Hi [@Kristian Overgaard](/t5/user/viewprofilepage/user-id/5074707),

Welcome to the community.

While using the latest version of Linux Docker runners, would it be possible for you to try to use the image **docker:dind** as your Docker image as a service?

You can add the "definitions:" configuration below to your YAML file above the "pipelines:" config.

```
definitions:   services:      docker:         image: docker:dindpipelines:  branches:    'master':          - step:..........................................
```

Once done, try to run builds again.  
Let me know how it goes.

Regards,  
Mark C

comments: author: Michael Herzog
body: [@Mark C](/t5/user/viewprofilepage/user-id/1210823) I took over from Kristian and have changed the config as per your suggestion. I also recreated the runner and now it runs as expected.

Thanks.


author: Mark C
body: Hi [@Michael Herzog](/t5/user/viewprofilepage/user-id/5078321)

Great. Glad to know it works.  

Do let me know if you have further questions that I can help with and feel free to mark this question as answered as well.  

Regards,  
Mark C


author: Ramesh
body: Hi [@Mark C](/t5/user/viewprofilepage/user-id/1210823)   

I am also facing the same problem. But your above solution did not fix the problem for me. I am getting error "The Docker feature is not supported on this self-hosted runner's platform.". The error screenshot is attached below.  

![Screenshot from 2023-04-16 21-47-20-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/252074iB2EBBC7C758FB65E/image-size/large?v=v2&px=999 "Screenshot from 2023-04-16 21-47-20-1.png")  

Below is my bitbucket-pipelines.yml  

definitions:  
services:  
docker:  
image: docker:dind  
pipelines:  
default:  
- step:  
name: 'Step1'  
runs-on:  
- self.hosted  
- linux.shell  
script:  
- echo "1.This step of pipeline will run on a self hosted runner.";  
- docker version  
- echo "2.This step of dtf-chain-handler pipeline, has successfully executed.";  
services:  
- docker  

I am facing big challenges of running docker commands from my self-hosted, linux-shell runner. I have been looking for solution for this problem for several days, but I could not get any solution online even not in Atlassian docs. Please provide the solution for this as soon as possible.  
Thanks,  
Ramesh


Tags: bitbucket-cloud

bitbucket-pipelines

bitbucket-runners

cloud