美文网首页droneDocker
drone学习笔记-发布镜像

drone学习笔记-发布镜像

作者: forrestsun | 来源:发表于2017-08-18 14:49 被阅读121次

    测试drone部署镜像又遇到N个坑。第一个就是拉取镜像被墙。好吧,这个可以通过国内镜像解决。另一个就是一直在报的错误

    Failed to create btrfs snapshot: inappropriate ioctl for device

    硬件设置还是synology 716 + II
    .drone.yml

    # workspace:
    #   base: /go
    #   path: src/test/demo
    
    pipeline:
      # build:
      #   image: golang:latest
      #   commands:
      #     - go test
      publish:
        image: plugins/docker
        repo: sunsl/demo
        tags : latest
        debug: true
          
    # services:
    #   database:
    #     image: mongo:latest
    
    编译错误
    群晖docker信息
    从信息中可以看到 Storage Driver为btrfs
    Use the BTRFS storage driver文中有这样的提示:

    Note: The btrfs storage driver is only supported on Docker CE on Ubuntu or Debian, and Docker EE / CS Engine on SLES.

    折腾了一天多的时间,看到这里郁闷了,好吧暂时放弃在群晖下测试drone,换服务器测试.....

    ==,先梳理下思路,看看还有什么没测试到的地方

    1. docker运行在btrfs存储上
    2. docker启动drone的server和agent容器
    3. drone根据配置文件启动一个测试容器(与drone是同一层级的容器)
    4. 测试容器内启动一个docker并根据dockerfile生成镜像文件(Docker in Docker)

    逐步测试:

    1. 在最外层测试创建镜像 (测试通过)

    Dockerfile

    FROM alpine
    RUN echo "Hello docker!"
    RUN echo "make dir"
    RUN mkdir -p /data/db
    RUN echo "expose port"
    EXPOSE 8000
    

    编译

     sudo docker build -t sunsl/demo .
    Sending build context to Docker daemon 2.048 kB
    Step 1 : FROM alpine
     ---> 7328f6f8b418
    Step 2 : RUN echo "Hello docker!"
     ---> Running in ce54f9d9a8e6
    Hello docker!
     ---> ef0ff48accdc
    Removing intermediate container ce54f9d9a8e6
    Step 3 : RUN echo "make dir"
     ---> Running in 6fa6e5a214e9
    make dir
     ---> eae38249e291
    Removing intermediate container 6fa6e5a214e9
    Step 4 : RUN mkdir -p /data/db
     ---> Running in 7ff9d7c7f1bd
     ---> cb5244f6649e
    Removing intermediate container 7ff9d7c7f1bd
    Step 5 : RUN echo "expose port"
     ---> Running in 36e80521a0b2
    expose port
     ---> aa9dc796f37a
    Removing intermediate container 36e80521a0b2
    Step 6 : EXPOSE 8000
     ---> Running in 686876f7af63
     ---> b6081a0bce0d
    Removing intermediate container 686876f7af63
    Step 7 : RUN echo "completed!!!"
     ---> Running in c227d0885785
    completed!!!
     ---> 610405572a84
    Removing intermediate container c227d0885785
    Successfully built 610405572a84
    
    1. 启动一个library/docker在其内部创建镜像(Docker in Docker) 测试正常!!!
    sudo docker run -it --privileged --name some-docker -d docker:17.07.0-ce-dind
    
    admin@sunsl-dev:~$ sudo docker run -it --privileged --name some-docker -d docker:17.07.0-ce-dind
    f131d5b26279e7023d6c5a6224c63e1aaa96ff4882aa3975a14031293a51712c
    
    admin@sunsl-dev:~$ sudo docker run -it --rm --link some-docker:docker docker sh
    ~ # mkdir docker
    ~ # vi Dockerfile
    ~ # docker build -t sunsl/demo .
    Sending build context to Docker daemon  3.584kB
    Step 1/7 : FROM daocloud.io/library/alpine:latest
     ---> 7328f6f8b418
    Step 2/7 : RUN echo "Hello docker!"
     ---> Running in 3d04694eef2c
    Hello docker!
     ---> 6635ba3812c5
    Removing intermediate container 3d04694eef2c
    Step 3/7 : RUN echo "make dir"
     ---> Running in 4d09d0b04bcb
    make dir
     ---> 30fc023d529e
    Removing intermediate container 4d09d0b04bcb
    Step 4/7 : RUN mkdir -p /data/db
     ---> Running in 4947b984c06f
     ---> 34a97a2eb15e
    Removing intermediate container 4947b984c06f
    Step 5/7 : RUN echo "expose port"
     ---> Running in 4f70ac65e998
    expose port
     ---> a45dd54382f5
    Removing intermediate container 4f70ac65e998
    Step 6/7 : EXPOSE 8000
     ---> Running in 172ee2942a7e
     ---> c41f37ed56d8
    Removing intermediate container 172ee2942a7e
    Step 7/7 : RUN echo "completed!!!"
     ---> Running in a73429ff68c8
    completed!!!
     ---> ba0d6edfd0db
    Removing intermediate container a73429ff68c8
    Successfully built ba0d6edfd0db
    Successfully tagged sunsl/demo:latest
    
    1. 测试是否与群晖登录权限有关 (无效)
      手动测试全部正常,考虑是否是与权限有关。因不知道drone是否在启动docker in docker是追加了权限,所以尝试启动群晖的root权限运行drone并设置docker的--privileged参数 。参考:群晖root密码设置

    4.想到一个问题,在手动测试docker in docker时的info信息如下:

    admin@sunsl-dev:~$ sudo docker run -it --rm --link some-docker:docker docker info
    ……
    Server Version: 17.07.0-ce-rc2 #版本号
    Storage Driver: vfs            #这里才是重点
    ……
    Kernel Version: 3.10.102
    Operating System: Alpine Linux v3.6 (containerized)
    OSType: linux
    Architecture: x86_64
    CPUs: 4
    Total Memory: 7.719GiB
    ……
    

    详细测试记录:docker run docker 手动测试记录


    看到区别了吗?群晖存存格式是btrfs,而docker内用的是vfs格式!!!跪了!!!
    然后....TMD继续找资料,如何设置配置文件啊。

    storage_driver
    supports aufs, overlay or vfs drivers

    .drone.yml

    ……省略其它pipeline部分
    publish:
        image: plugins/docker
        registry: 192.168.123.202:55000
        repo: 192.168.123.202:55000/sunsl/demo
        tags : latest
        debug: true
        insecure: true         #私有仓库未设置HTTPS需要启用这个选项
        storage_driver: vfs    #出错原因就是它
    ……省略其它pipeline部分
    
    两天的成果啊!!!

    参考:

    相关文章

      网友评论

        本文标题:drone学习笔记-发布镜像

        本文链接:https://www.haomeiwen.com/subject/lupgrxtx.html