Cannot use custom plugin based on drone-ecr, having permission errors

Hello, I started adding some custom steps to the drone-ecr plugin.

The problems comes with my fork, cloned drone-ecr git repository build docker image and pushed it to my docker hub reopository. In order to test this fork in a project I set the .drone.yml file of another project to:

  publish:
    # image: plugins/ecr
    image: myuser/drone-ecr
    repo: myuser/some_application
    dockerfile: Dockerfile
    debug: true
    tag: latest

And got these errors

time="2017-05-23T19:46:17Z" level=warning msg="the \"-g / --graph\" flag is deprecated. Please use \"--data-root\" instead" 
time="2017-05-23T19:46:17.818410255Z" level=warning msg="could not change group /var/run/docker.sock to docker: group docker not found" 
time="2017-05-23T19:46:17.820189973Z" level=info msg="libcontainerd: new containerd process, pid: 31" 
time="2017-05-23T19:46:17.880942948Z" level=warning msg="containerd: low RLIMIT_NOFILE changing to max" current=1024 max=4096 
time="2017-05-23T19:46:18.830292102Z" level=error msg="'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded." 
time="2017-05-23T19:46:18.830989919Z" level=error msg="'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded." 
time="2017-05-23T19:46:18.886498181Z" level=info msg="Graph migration to content-addressability took 0.00 seconds" 
time="2017-05-23T19:46:18.886781211Z" level=warning msg="Your kernel does not support cgroup blkio weight" 
time="2017-05-23T19:46:18.886800043Z" level=warning msg="Your kernel does not support cgroup blkio weight_device" 
time="2017-05-23T19:46:18.886893880Z" level=warning msg="mountpoint for pids not found" 
time="2017-05-23T19:46:18.887082782Z" level=info msg="Loading containers: start." 
time="2017-05-23T19:46:18.887933966Z" level=warning msg="Running modprobe bridge br_netfilter failed with message: modprobe: can't change directory to '/lib/modules': No such file or directory\n, error: exit status 1" 
time="2017-05-23T19:46:18.888625139Z" level=warning msg="Running modprobe nf_nat failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1" 
time="2017-05-23T19:46:18.889178738Z" level=warning msg="Running modprobe xt_conntrack failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1" 
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.0: can't initialize iptables table `nat': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
 (exit status 3)
time="2017-05-23T19:46:33Z" level=fatal msg="Error authenticating: exit status 1" 

The logs got using the original image (plugins/ecr):

time="2017-05-23T19:35:15.339600441Z" level=info msg="libcontainerd: new containerd process, pid: 33" 
time="2017-05-23T19:35:15.457652519Z" level=warning msg="containerd: low RLIMIT_NOFILE changing to max" current=1024 max=4096 
time="2017-05-23T19:35:16.361907883Z" level=error msg="devmapper: Udev sync is not supported. This will lead to data loss and unexpected behavior. Install a dynamic binary to use devicemapper or select a different storage driver. For more information, see https://docs.docker.com/engine/reference/commandline/daemon/#daemon-storage-driver-option" 
time="2017-05-23T19:35:16.363552821Z" level=error msg="'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded." 
time="2017-05-23T19:35:16.414011859Z" level=info msg="Graph migration to content-addressability took 0.00 seconds" 
time="2017-05-23T19:35:16.414213195Z" level=warning msg="Your kernel does not support cgroup blkio weight" 
time="2017-05-23T19:35:16.414230476Z" level=warning msg="Your kernel does not support cgroup blkio weight_device" 
time="2017-05-23T19:35:16.414341319Z" level=warning msg="mountpoint for pids not found" 
time="2017-05-23T19:35:16.414533022Z" level=info msg="Loading containers: start." 
time="2017-05-23T19:35:16.419084099Z" level=warning msg="Running modprobe bridge br_netfilter failed with message: modprobe: can't change directory to '/lib/modules': No such file or directory\n, error: exit status 1" 
time="2017-05-23T19:35:16.420197207Z" level=warning msg="Running modprobe nf_nat failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1" 
time="2017-05-23T19:35:16.420795988Z" level=warning msg="Running modprobe xt_conntrack failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1" 
time="2017-05-23T19:35:16.479312115Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.18.0.0/16. Daemon option --bip can be used to set a preferred IP address" 
time="2017-05-23T19:35:16.511901478Z" level=info msg="Loading containers: done." 
time="2017-05-23T19:35:16.511989858Z" level=info msg="Daemon has completed initialization" 
time="2017-05-23T19:35:16.512006724Z" level=info msg="Docker daemon" commit=7392c3b graphdriver=vfs version=1.12.5 
time="2017-05-23T19:35:16.518949795Z" level=info msg="API listen on /var/run/docker.sock" 

I get permissions errors without doing any change to the original code, but when using as image plugins/ecr all works like a charm. Is there something extra I have to do in order to use a custom plugin based on plugins/ecr?

Thanks in advance

I realized what was my problem, after checking dockerfiles ecr plugin uses docker plugin which in turn uses docker image so checking docs for docker image I should have been using the privileged option, then added that to my .drone.yml file and it worked.

There is also an environment variable that can be used to whitelist a plugin to run privileged automatically. This is how we run the docker, gcr and ecr plugins.

Example:

DRONE_PLUGIN_PRIVILEGED=octocat/my-ecr-plugin

1 Like

Thanks! that’s very good information