docker CircleCI集成无法启动守护程序

时间:2018-06-16 20:02:39

标签: docker daemon circleci

我正在执行一个应该设置和安装docker的CircleCI脚本,以便我可以部署到Dockerhub,但是Docker守护程序在安装后无法正常启动。

这些是我想要设置的circleCI自动化

---
- run:
          name: Install Docker client
          command: |
            set -x
            VER="17.03.0-ce"
            curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
            sudo tar -xz -C /tmp -f /tmp/docker-$VER.tgz
            sudo mv /tmp/docker/docker* /usr/bin/
            sudo curl -L "https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
            sudo chmod +x  /usr/bin/docker-compose  
            docker --version
            # sudo service docker stop
            sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &
            sudo docker info            
            docker run hello-world

      - run:
         name: Build Docker image
         command: docker build -t joethecoder2/spring-boot-web:$CIRCLE_SHA1 .

      - run:
          name: Push to DockerHub
          command: |
            docker login -u$DOCKERHUB_LOGIN -p$DOCKERHUB_PASSWORD
            docker push joethecoder2/spring-boot-web:$CIRCLE_SHA1
 ---

这些是错误结果,表明即使在尝试安装并启动守护程序之后,docker守护程序也无法启动。

#!/bin/bash -eo pipefail
set -x
VER="17.03.0-ce"
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
sudo tar -xz -C /tmp -f /tmp/docker-$VER.tgz
sudo mv /tmp/docker/docker* /usr/bin/
sudo curl -L "https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
sudo chmod +x  /usr/bin/docker-compose  
docker --version
# sudo service docker stop
sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &
sudo docker info            
docker run hello-world
+ VER=17.03.0-ce
+ curl -L -o /tmp/docker-17.03.0-ce.tgz https://get.docker.com/builds/Linux/x86_64/docker-17.03.0-ce.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

100 26.5M  100 26.5M    0     0  57.4M      0 --:--:-- --:--:-- --:--:-- 57.3M
+ sudo tar -xz -C /tmp -f /tmp/docker-17.03.0-ce.tgz
+ sudo mv /tmp/docker/docker /tmp/docker/docker-containerd /tmp/docker/docker-containerd-ctr /tmp/docker/docker-containerd-shim /tmp/docker/docker-init /tmp/docker/docker-proxy /tmp/docker/docker-runc /tmp/docker/dockerd /usr/bin/
++ uname -s
++ uname -m
+ sudo curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-Linux-x86_64 -o /usr/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

100   617    0   617    0     0   6548      0 --:--:-- --:--:-- --:--:--  6563

100 7857k  100 7857k    0     0  27.6M      0 --:--:-- --:--:-- --:--:-- 27.6M
+ sudo chmod +x /usr/bin/docker-compose
+ docker --version
Docker version 17.03.0-ce, build 60ccb22
+ sudo docker info
+ sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
nohup: appending output to 'nohup.out'
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Exited with code 1
---

为什么Docker守护程序在CircleCI内正常连接?我尝试通过执行以下操作来启动守护程序:

sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. 

为什么docker守护进程没有运行?

在circleCI的脚本中运行docker服务的脚本步骤是什么?

0 个答案:

没有答案