Build and push docker image

Hi guys,

I am trying to use Gitlab to build and push Docker images, using gitlab-runner locally.
.gitlab-ci.yml:
docker-build:
# Official docker image.
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- export
- docker login -u “$CI_REGISTRY_USER” -p “$CI_REGISTRY_PASSWORD” $CI_REGISTRY
script:
- docker build --pull -t “$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG” .
- docker push “$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG”
except:
- master

Output:
$ sudo gitlab-runner exec docker docker-build
Runtime platform arch=amd64 os=darwin pid=5878 revision=ece86343 version=13.5.0
WARNING: You most probably have uncommitted changes.
WARNING: These changes will not be tested.
Running with gitlab-runner 13.5.0 (ece86343)
Preparing the “docker” executor
Using Docker executor with image docker:latest …
Starting service docker:dind …
Pulling docker image docker:dind …
Using docker image sha256:71edd6fcc7ef9b0427a2fc666a2379460622769e6ed1440583c30638c9403d50 for docker:dind with digest docker@sha256:ef1483664a3eb469cb5abbef75aa27fc7e3ce0371555270e65678f93cd8192bd …
Waiting for services to be up and running…

*** WARNING: Service runner--project-0-concurrent-0-dd7144c66436b237-docker-0 probably didn't start properly.

Health check error:
service "runner--project-0-concurrent-0-dd7144c66436b237-docker-0-wait-for-service" timeout

Health check container logs:


Service container logs:
2020-11-24T12:20:55.462359500Z Generating RSA private key, 4096 bit long modulus (2 primes)
2020-11-24T12:20:56.280294000Z ....................................................................................++++
2020-11-24T12:20:56.380436200Z ...........++++
2020-11-24T12:20:56.381340600Z e is 65537 (0x010001)
2020-11-24T12:20:56.411622700Z Generating RSA private key, 4096 bit long modulus (2 primes)
2020-11-24T12:20:57.468498200Z .......................................................................................................................................++++
2020-11-24T12:20:57.633974000Z ....................++++
2020-11-24T12:20:57.634934100Z e is 65537 (0x010001)
2020-11-24T12:20:57.686471200Z Signature ok
2020-11-24T12:20:57.686550600Z subject=CN = docker:dind server
2020-11-24T12:20:57.686726100Z Getting CA Private Key
2020-11-24T12:20:57.707417100Z /certs/server/cert.pem: OK
2020-11-24T12:20:57.715142500Z Generating RSA private key, 4096 bit long modulus (2 primes)
2020-11-24T12:20:58.088967600Z ..................................................++++
2020-11-24T12:20:58.203171500Z ..............++++
2020-11-24T12:20:58.204252000Z e is 65537 (0x010001)
2020-11-24T12:20:58.251481200Z Signature ok
2020-11-24T12:20:58.251533700Z subject=CN = docker:dind client
2020-11-24T12:20:58.251926800Z Getting CA Private Key
2020-11-24T12:20:58.272934000Z /certs/client/cert.pem: OK
2020-11-24T12:20:58.279729200Z mount: permission denied (are you root?)
2020-11-24T12:20:58.279966200Z Could not mount /sys/kernel/security.
2020-11-24T12:20:58.280006100Z AppArmor detection and --privileged mode might break.
2020-11-24T12:20:58.281977100Z mount: permission denied (are you root?)

*********

Pulling docker image docker:latest ...
Using docker image sha256:6972c414f322dfa40324df3c503d4b217ccdec6d576e408ed10437f508f4181b for docker:latest with digest docker@sha256:9170b902404a630a982a2a6473442d3e2cc2342b66345f7a9cf148f8affcf5d3 ...
Preparing environment
Running on runner--project-0-concurrent-0 via Carloss-MacBook-Pro.local...
Getting source from Git repository
Fetching changes...
Initialized empty Git repository in /builds/project-0/.git/
Created fresh repository.
Checking out f0f9681c as feature/gitlab...

Skipping Git submodules setup
Executing "step_script" stage of the job script
$ export
export CI='true'
export CI_BUILDS_DIR='/builds'
export CI_COMMIT_BEFORE_SHA='50ea79d141bfecdda509ffb24c0f8c27e0456b4e'
export CI_COMMIT_REF_NAME='feature/gitlab'
export CI_COMMIT_SHA='f0f9681c87e6b6ef18cb45b562bc8968ebbdef64'
export CI_CONCURRENT_ID='0'
export CI_CONCURRENT_PROJECT_ID='0'
export CI_DISPOSABLE_ENVIRONMENT='true'
export CI_JOB_ID='1'
export CI_JOB_IMAGE='docker:latest'
export CI_JOB_NAME='docker-build'
export CI_JOB_STAGE='build'
export CI_JOB_STATUS='running'
export CI_JOB_TOKEN=''
export CI_PROJECT_DIR='/builds/project-0'
export CI_PROJECT_ID='0'
export CI_REPOSITORY_URL='/Users/user/Projects/company'
export CI_RUNNER_EXECUTABLE_ARCH='darwin/amd64'
export CI_RUNNER_REVISION='ece86343'
export CI_RUNNER_SHORT_TOKEN=''
export CI_RUNNER_VERSION='13.5.0'
export CI_SERVER='yes'
export CI_SERVER_NAME='GitLab CI'
export CI_SERVER_REVISION=''
export CI_SERVER_VERSION=''
export DOCKER_HOST='tcp://docker:2375'
export DOCKER_TLS_CERTDIR='/certs'
export DOCKER_VERSION='19.03.13'
export FF_CMD_DISABLE_DELAYED_ERROR_LEVEL_EXPANSION='false'
export FF_NETWORK_PER_BUILD='false'
export FF_RESET_HELPER_IMAGE_ENTRYPOINT='true'
export FF_SHELL_EXECUTOR_USE_LEGACY_PROCESS_KILL='false'
export FF_SKIP_NOOP_BUILD_STAGES='true'
export FF_USE_DIRECT_DOWNLOAD='true'
export FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY='true'
export GITLAB_CI='true'
export HOME='/root'
export HOSTNAME='runner--project-0-concurrent-0'
export OLDPWD='/'
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
export PWD='/builds/project-0'
export SHLVL='3'
$ docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
Error: Cannot perform an interactive login from a non TTY device
Cleaning up file based variables
ERROR: Job failed: exit code 1
FATAL: exit code 1    

$CI_JOB_TOKEN is always empty also.