drone學習筆記-釋出映象

weixin_34320159發表於2017-08-18

測試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

3340499-602d3d679f1e33e5.PNG
編譯錯誤

3340499-cb32196d02ae8dcd.PNG
群暉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.

3340499-978b6ff80c3a6b63.PNG

折騰了一天多的時間,看到這裡鬱悶了,好吧暫時放棄在群暉下測試drone,換伺服器測試.....

==,先梳理下思路,看看還有什麼沒測試到的地方

3340499-a7ca547ba0b00c5d.PNG
  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 手動測試記錄

3340499-66395b5ef39b4e86.PNG

看到區別了嗎?群暉存存格式是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部分
3340499-5a842f918e4c213d.PNG
兩天的成果啊!!!

參考:

相關文章