Evryvilanislemn
Evryvilanislemn

Reputation: 31

Self Hosted Linux Runner doesnt use docker daemon. but docker is installed and works when using ssh to access it

I am trying to run docker commands from a bitbucket runner(linux.shell) and even though the docker service is running as shown the command from bitbucket-pipelines.yml doesn't work.

bitbucket-pipelines.yml

pipelines:
  default:
    - step:
        name: Deploy to production
        runs-on:
          - 'linux.shell'
          - 'self.hosted'
        # trigger: manual  # Uncomment to make this a manual deployment.
        script:
          - echo "Deploying to production environment"
          - sudo lsof -i -P -n
          - systemctl --type=service --state=running
          - docker ps -a
          - chmod +x start-server.sh
          - ./start-server.sh

I am expecting to run the docker command for now. The docker command works fine when executing the runner in the same instance shown in the pic above. Using a self.hosted linux.shell as described when creating runners in bit-bucket repo

echo $PATH:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

which docker: /usr/bin/docker

related images: showing how docker daemon isn't working: https://ibb.co/vQw5X5g echo $PATH: https://ibb.co/6y2TPRQ

ERROR:

+ docker ps -a

Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

Upvotes: 2

Views: 976

Answers (2)

Anton Z
Anton Z

Reputation: 13

By default runner sets DOCKER_HOST to tcp://localhost:2375. If you want use local docker on selfhosted agent just set DOCKER_HOST to empty string. Then your docker executable will user local docker daemon. It is explained here https://community.atlassian.com/t5/Bitbucket-questions/Pipelines-access-docker-host/qaq-p/2184196

Upvotes: 1

snowmanstark
snowmanstark

Reputation: 180

I had this similar issue in a jenkins worker node and adding sleep 60 worked like a charm.

Upvotes: 1

Related Questions