无法在circleci作业中使用docker

时间:2018-03-28 09:09:32

标签: docker circleci

这是我的circleci配置文件

version: 2
jobs:
  build: 
    docker:
      - image: 12345678.dkr.ecr.us-west-1.amazonaws.com/circleci/build:20180319
    steps:
      - 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 https://download.docker.com/linux/ubuntu/gpg | apt-key add -
            apt-key fingerprint 0EBFCD88
            add-apt-repository \
              "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
              $(lsb_release -cs) \
              stable"
            apt-get update
            apt-get install -y docker-ce
            docker --version
      - run:
          name: Build and deploy docker images
          command: |
            docker build -t myapp .

安装Docker'基本上是按照此处的说明建模的:https://docs.docker.com/install/linux/docker-ce/ubuntu/

当作业执行到行docker build时,我收到此错误:

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

所以我在构建任务之前尝试service start docker。但现在我收到了这个错误:

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

这是由于码头工人的限制。它不允许ulimit -u <a large number>

如何绕过此限制并启动docker守护程序?

1 个答案:

答案 0 :(得分:1)

在使用docker之前添加步骤setup_remote_docker。即。

  - setup_remote_docker
  - run:
      name: Build and deploy docker images
      command: |
        docker build -t myapp .