前阵子,k8s 是搭建起来了.但是这玩意更新太快,3个月后, 以前的方法不好使了...又有新坑了...
干脆就只跑 Docker 吧....
我擦,Docker也跑不起来了...说
- docker:dind
干脆就只跑 Docker 吧....
我擦,Docker也跑不起来了...说
**docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.**
以前只要在 .gitlab-ci.yml 里面填写 标红的就可以了.但是现在不行,会报 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
services:- docker:dind
variables:
DOCKER_DRIVER: overlay
build:
stage: build
script:
- export DOCKER_HOST="tcp://localhost:2375"
build-master: stage: build script: - echo $CI_REGISTRY_PASSWORD | docker login -u "$CI_REGISTRY_USER" $CI_REGISTRY --password-stdin - docker build .
(注意, $CI_REGISTRY 这些环境变量是要填写在 Gitlab web 环境变量中的)
研究后,要在 gitlab-run 的 文件中包含 volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]
sudo cat /etc/gitlab-runner/config.toml
concurrent = 1check_interval = 0
[[runners]] name = "k8s" url = "https://x.net" token = "xxxxxxxxxx" executor = "docker" [runners.docker] tls_verify = false privileged = true disable_cache = false volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"] shm_size = 0 [runners.cache]
这样就可以 build 你项目中的 Dockerfile 了~
贴个完整的 .gitlab.yml 文件:
image: docker:gitservices: - docker:dindvariables: DOCKER_DRIVER: overlay before_script:
- echo $CI_REGISTRY_PASSWORD | docker login -u "$CI_REGISTRY_USER" $CI_REGISTRY --password-stdin
build-master: stage: build script: - docker build .
only: - master
build: stage: build script: - docker build . except: - master
完整的Dockerfile:
FROM x.sn.mynetnaxxme.net:5001/root/buildroot-imx6q:latest
#RUN apt-get update && \# apt-get install -qq -y --no-install-recommends \# rsync bc locales u-boot-tools lzop && \# locale-gen en_US.UTF-8
#RUN apt-get clean
RUN git clone https://x.net/root/dl.git xx
RUN mkdir /opt/freescale/usr/local -p && \ tar xf dl/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12.tar.gz -C /opt/freescale/usr/local/ && \ export CROSS_COMPILE=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-none-linux-gnueabi- && \ export PATH=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin:$PATH && \ tar xf dl/linux-3.0.35.tar.bz2 && cp dl/buildroot-config/devtmpfs.config linux-3.0.35/ && \ cp dl/buildroot-config/devtmpfs.config linux-3.0.35/.config && \ pwd && ls -la && ls dl/ -la && \ cp dl/patch/timeconst.pl linux-3.0.35/kernel/ && \ export CPUS=`grep -c processor /proc/cpuinfo` && \ cd linux-3.0.35 && make devtmpfs.config && make ARCH=arm uImage -j${CPUS} 2>&1 | tee build-kernel.log | grep -i error
RUN tar xf dl/buildroot-2014.05.tar.bz2 && \ cp dl/buildroot-config/buildroot.config buildroot-2014.05/.config && \ cp dl/buildroot-config/busybox.config buildroot-2014.05/package/busybox/busybox-1.22.x.config && \ cp dl/patch/101-cfns.patch buildroot-2014.05/package/gcc/4.7.3/ && \ cd buildroot-2014.05 && make 2>&1 | tee build-buildroot.log | grep -i error

评论
发表评论