continuous integration - Docker: permission denied while trying to connect to Docker Daemon with local CircleCI build -


i have simple config.yml:

version: 2  jobs:   build:     working_directory: ~/app     docker:       - image: circleci/node:8.4.0     steps:       - checkout       - run: node -e "console.log('hello nodejs ' + process.version + '\!')"       - run: yarn       - setup_remote_docker       - run: docker build . 

all does: boot node image, test if node running, yarn install , docker build.

my dockerfile nothing special; has copy , entrypoint.

when run circleci build on macbook air using docker native, following error:

got permission denied while trying connect docker daemon socket @ unix://[...]

if change docker build . command to: sudo docker build ., works planned, locally, circleci build.
however, pushing change circleci result in error: cannot connect docker daemon @ unix:///var/run/docker.sock. docker daemon running?

so, summarize: using sudo works, locally, not on circleci itself. not using sudo works on circleci, not locally.

is circleci staff has fix, or there can do?

for reference, have posted question on circleci forums well.

i've created workaround myself.

in first step of config.yml, run command:

if [[ $circle_env == *"localbuild"* ]];   echo "this local build. enabling sudo docker"   echo sudo > ~/sudo else   echo "this not local build. disabling sudo docker"   touch ~/sudo fi 

afterwards, can this:

eval `cat ~/sudo` docker build . 

explanation:

the first snippet checks if circleci-provided environment variable circle_env contains localbuild. true when running circleci build on local machine. if true, creates file called sudo contents sudo in home directory. if false, creates file called sudo no contents in home directory.

the second snippet opens ~/sudo file, , executes arguments give afterwards. if ~/sudo file contains "sudo", command in example become sudo docker build ., if doesn't contain anything, become docker build ., space before it, ignored.

this way, both local (circleci build) builds , remote builds work.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -