moby/datakit

Unable to run CI example (permission denied)

Thegaram opened this issue · 7 comments

I am trying to run the DataKitCI example under ci/skeleton. When I try to build the container using the command from the readme, I get the following error:

$ docker build -t my-ci --build-arg CONFIG=exampleCI .
Sending build context to Docker daemon  11.26kB
Step 1/9 : FROM datakit/ci
 ---> f16cddfd6f02
Step 2/9 : ARG CONFIG=exampleCI
 ---> Using cache
 ---> c96660dbfaef
Step 3/9 : ADD . /datakit-ci
 ---> Using cache
 ---> 835d5519c636
Step 4/9 : WORKDIR /datakit-ci
 ---> Using cache
 ---> 709a5c6fd874
Step 5/9 : RUN sudo chown opam .
 ---> Using cache
 ---> c083e3152b38
Step 6/9 : RUN opam config exec make $CONFIG && ln _build/skeleton/$CONFIG.native /datakit-ci/datakit-ci && rm -rf _build
 ---> Running in edcdb5c45eaf
ocamlbuild -use-ocamlfind exampleCI.native
Exception Sys_error("/datakit-ci/_build/_log: Permission denied").
make: *** [Makefile:6: exampleCI] Error 100
The command '/bin/sh -c opam config exec make $CONFIG && ln _build/skeleton/$CONFIG.native /datakit-ci/datakit-ci && rm -rf _build' returned a non-zero code: 2

What did I miss? Any help is appreciated.

Did you already run make in that directory? Maybe you already have a _build directory owned by a different user? If not, try changing the chown command in the Dockerfile to chown -R and see if that helps...

Actually, I think this example is just broken. Could you try the fix in #619?

Yep, it works now. Thanks for the quick fix @talex5!

The way I'm trying to run the CI example:

  1. Run DataKit server
$ docker run -it --net datakit-net --name datakit -v [path_to_git_repo]:/data -p 5640:5640 datakit/db
  1. Check server by running DataKit client
$ docker run -it --privileged --net datakit-net datakit/client
bash-4.3$ ls -l /db/branch/master/ro/
[git_repos_contents]

From this, and the subsequent server logs, I assume that the server is running and reachable on tcp://0.0.0.0:5640.

  1. Run CI
$ docker run --name my-ci --net datakit-net -p 8443:8443 my-ci --metadata-store tcp:0.0.0.0:5640
2018-03-02 13:12.13 INF [datakit-ci] Generating new private key...
2018-03-02 13:12.13 APP [datakit-ci] >>> Configure the CI by visiting
                                     https://127.0.0.1:8443/auth/intro/SFEq6uYvHCgKJjg1iOrHy4BwIG2heYGc
2018-03-02 13:12.13 INF [datakit-ci] Connecting to DataKit server on tcp:0.0.0.0:5640
2018-03-02 13:12.13 INF [datakit-ci] Starting monitor loop
2018-03-02 13:12.13 WRN [datakit-ci] Failed to connect to DataKit: (Failure
   "Failed to connect to DataKit server at proto=\"tcp\" addr=\"0.0.0.0:5640\": (Failure\
  \n  \"Error connecting socket to 9p endpoint tcp:0.0.0.0:5640: Unix.Unix_error(Unix.ECONNREFUSED, \\\"connect\\\", \\\"\\\")\")") (will retry in 10s)

Could you please point out what I'm doing wrong? (I would create a new issue but I assume this is due to some misconfiguration on my side.)

Okay, it seems like the CI can connect if I use 172.19.0.2:5640 (taken from the output of docker network inspect datakit-net).

You have to give the actual address of the server. 0.0.0.0 is a special address that means "listen on any interface", but you can't use it as a destination. You should be able to use --metadata-store tcp:datakit:5640.

Yeah, it works with tcp:datakit:5640, thanks!