How to run docker build in a circleci job that uses docker?


I want to use circleci to build and deploy a docker image to a repository when there is a change in the main branch of my github project.

My docker image is based on ubuntu:16.04

When I run docker build it emits this error message:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

If I try service docker start I got this:

/etc/init.d/docker: 96: ulimit: error setting limit (Operation not permitted)

Has anyone encountered similar issue? If so, what is a solution?


Do you specifically need to base yourself on the plain Ubuntu image? Use docker:17.05.0-ce-git as your base if you want Docker installed and working if you can.


Yes, I need to use an image based on ubuntu because the bespoke docker image is already set up with all the essential dev tools specific to this particular distro for my project.


If you really can’t change, then please show us how you’ve installed Docker - showing the whole config is probably best.


I basically followed the instructions at this url: The step ‘Install docker’ captures the setup process.

version: 2
      - image:
      - checkout
      - run:
          name: Install docker
          command: |
            apt-get update --fix-missing
            apt-get install -y apt-transport-https ca-certificates software-properties-common
            curl -fsSL | apt-key add -
            apt-key fingerprint 0EBFCD88
            add-apt-repository \
              "deb [arch=amd64] \
              $(lsb_release -cs) \
            apt-get update
            apt-get install -y docker-ce
            docker --version
      - run:
          name: Build and deploy docker images
          command: pynt build_and_deploy_docker_images

What is missing in the above is service docker start which failed due to the ulimit problem


I’ve not come across the error before, but this simple search revealed this similar problem.

(I added “sudo” to my search terms, as some Docker permission problems are related to whether one is a member of the docker group or not. However, on reading those answers, I think that’s a red herring).


The ‘answer’ you cited is not applicable. My question is about overcoming the ulimit problem when starting docker daemon.


I’m assuming you’ve read
Rolling your own and manually starting your own docker is highly non-standard but I’m sure it’s doable.
I can’t give you the answer you want, but I suggest basing your build:20180319 and all its pynt goodies off of an official circleci image such as circleci/python:2.7.14. Then in config.yml

  1. Remove all the docker installation stuff
  2. Remove the service start docker
  3. Add a setup_remote_docker incantation as per the docs


This approach works very well indeed. I do this because I operate a microservices app, and spinning it up in Circle using Docker Compose was fairly straightforward, because that’s how I run it locally and in production.


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.