我有一个如下所示的 Dockerfile:
# Pull base image
FROM openjdk:8
ENV SCALA_VERSION 2.12.2
ENV SBT_VERSION 0.13.15
# Scala expects this file
RUN touch /usr/lib/jvm/java-8-openjdk-amd64/release
# Install Scala
## Piping curl directly in tar
RUN \
curl -fsL http://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz | tar xfz - -C /root/ && \
echo >> /root/.bashrc && \
echo 'export PATH=~/scala-$SCALA_VERSION/bin:$PATH' >> /root/.bashrc
# Install sbt
RUN \
curl -L -o sbt-$SBT_VERSION.deb http://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb && \
dpkg -i sbt-$SBT_VERSION.deb && \
rm sbt-$SBT_VERSION.deb && \
apt-get update && \
apt-get …Run Code Online (Sandbox Code Playgroud) 我想在 Gitlab 中运行 Testontainers 来测试 Spring Boot 应用程序。创建 Gitlab 运行程序后(更改了 URL 和令牌):
sudo gitlab-runner register -n \
--url https://gitlab.com/ \
--registration-token REGISTRATION_TOKEN \
--executor docker \
--description "My Docker Runner" \
--docker-image "docker:19.03.12" \
--docker-privileged \
--docker-volumes "/certs/client"
Run Code Online (Sandbox Code Playgroud)
我写了一个简单的 ci 管道:
stages:
- test
services:
- docker:19.03.12-dind
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
test:
stage: test
image: amazoncorretto:11
script:
- java -version
- chmod +x gradlew
- ./gradlew test
tags:
- docker-dind
Run Code Online (Sandbox Code Playgroud)
测试看起来像:
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait; …Run Code Online (Sandbox Code Playgroud) 我正在尝试在一个正在运行的 ubuntu docker 容器中运行一些多容器构建测试,我用它来构建我的应用程序(通常,我有一个 Gitlab CI 设置)。
我发现当尝试运行指定内存限制的容器时,我遇到如下错误:
ERROR: for <service-name> Cannot start service <service-name>: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:385: applying cgroup configuration for process caused: cannot enter cgroupv2 "/sys/fs/cgroup/docker" with domain controllers -- it is in threaded mode: unknown
Run Code Online (Sandbox Code Playgroud)
这是一个(几乎)最小的工作示例:
# start from ubuntu base image
docker run -it --privileged ubuntu:18.04 /bin/bash
# once inside the container, install docker
apt-get update
apt-get remove docker docker-engine docker.io containerd runc
apt-get install -y apt-transport-https ca-certificates …Run Code Online (Sandbox Code Playgroud) 我正在尝试在dind:latest基于 alpine的图像中安装 azure-cli 。
对于上下文,我想使用它连接到 AKS 并通过 Gitlab 将应用程序部署到 Kubernetes。
在我的gitlab-ci.yml文件中,我从这个开始
image: docker:latest
services:
- docker:dind
Run Code Online (Sandbox Code Playgroud)
然后我尝试安装 azure-cli
deploy-to-k8s--dev: # k8s namespace "dev"
stage: deploy-to-k8s
# image: microsoft/azure-cli
script:
# I need the azure cli in the dind:latest container
# so install bash,curl and finally the cli
- apk update
- apk upgrade
- apk add bash
- apk add --no-cache curl
- curl -L https://aka.ms/InstallAzureCli | bash
- az
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
$ curl -L https://aka.ms/InstallAzureCli | …Run Code Online (Sandbox Code Playgroud) 如何在 kubernetes pod 中运行 docker 镜像?
我的一个队友定义了一个新的 docker 镜像并将其推送到我团队的私有注册表。我拥有一些在我们的 kubernetes 集群中运行的代码,我们需要让我的代码有效地运行docker run gcr.io/our-project/teammates-image:latest。
我一直在考虑在我们的 kubernetes pod 上启用 docker-in-docker,但我运气不佳。我目前正在试验,minikube每当我尝试时,docker run我都会得到:docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?..
我已经添加
securityContext:
privileged: true
到我的容器规范。我怀疑我需要更多配置,但还没有弄清楚是什么。
我也在尝试评估我是否可以kubectl run --image=gcr.io/our-project/teammates-image:lastest从 kubernetes pod 中进行。
是否有一种“正确”的方法可以从 kubernetes pod 中运行 docker 镜像?如何使用 docker-in-docker 运行镜像?
我正在尝试使用 gitlab CI 设置一项工作,以从 dockerfile 构建 docker 映像,但我位于代理后面。
我.gitlab-ci.yml的如下:
image: docker:stable
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
HTTP_PROXY: $http_proxy
HTTPS_PROXY: $http_proxy
http_proxy: $http_proxy
https_proxy: $http_proxy
services:
- docker:dind
before_script:
- wget -O - www.google.com # just to test
- docker search node # just to test
- docker info # just to test
build:
stage: build
script:
- docker build -t my-docker-image .
Run Code Online (Sandbox Code Playgroud)
wget有效,这意味着理论上代理设置是正确的
但命令docker search、docker info和docker build不起作用,显然是因为代理问题。
作业输出摘录:
$ docker search …Run Code Online (Sandbox Code Playgroud) 我正在安装了 Docker 的 AKS 集群内运行 GitHub 代理。我可以使用 VFS 存储驱动程序成功运行它,但是我想使用 Overlay 2,因为它更快。我收到以下消息:
sudo dockerd &
...
INFO[2021-06-12T22:38:41.674415376Z] containerd successfully booted in 0.029163s
INFO[2021-06-12T22:38:41.692284696Z] parsed scheme: "unix" module=grpc
INFO[2021-06-12T22:38:41.692316597Z] scheme "unix" not registered, fallback to default scheme module=grpc
INFO[2021-06-12T22:38:41.692340397Z] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock <nil> 0 <nil>}] <nil> <nil>} module=grpc
INFO[2021-06-12T22:38:41.692352097Z] ClientConn switching balancer to "pick_first" module=grpc
INFO[2021-06-12T22:38:41.693462211Z] parsed scheme: "unix" module=grpc
INFO[2021-06-12T22:38:41.693484611Z] scheme "unix" not registered, fallback to default scheme module=grpc
INFO[2021-06-12T22:38:41.693505611Z] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock <nil> 0 …Run Code Online (Sandbox Code Playgroud) 我想在 GKE 上安装 CI 工具,以便可以通过 Sysbox 运行 docker-in-docker。
为此,我需要安装 Sysbox 容器运行时。
在 GKE 中可以做到这一点吗?
我是詹金斯的新手。目前我有一个由 docker 启动的 jenkins 服务器,其中包含以下 docker-compose 文件:
\nversion: '3.7'\nservices:\n jenkins:\n image: jenkins/jenkins:lts\n privileged: true\n user: root\n ports:\n - 50000:50000\n container_name: jenkins\n volumes:\n - ~/jenkins:/var/jenkins_home\n - /var/run/docker.sock:/var/run/docker.sock\n - /usr/local/bin/docker:/usr/local/bin/docker\nRun Code Online (Sandbox Code Playgroud)\n然后我创建了一个简单的管道来测试 jenkins 内的 docker。这是管道脚本:
\nnode {\n stage "Create build output"\n \n sh "docker info"\n\n}\nRun Code Online (Sandbox Code Playgroud)\n错误消息如下:
\nStarted by user myuser\nRunning in Durability level: MAX_SURVIVABILITY\n[Pipeline] Start of Pipeline\n[Pipeline] node\nRunning on Jenkins in /var/jenkins_home/workspace/test-pip\n[Pipeline] {\n[Pipeline] stage (Create build output)\nUsing the \xe2\x80\x98stage\xe2\x80\x99 step without a block argument is deprecated\nEntering stage Create …Run Code Online (Sandbox Code Playgroud) jenkins jenkins-plugins docker docker-compose docker-in-docker
例子:
pavel@Z546:~/test/dind-volumes$ ls
test.txt
pavel@Z546:~/test/dind-volumes$ docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/app -w /app -it docker sh
/app # ls
test.txt
/app # pwd
/app
/app # docker run -v $(pwd):/app2 -w /app2 -it alpine sh
/app2 # ls
share tomita-cfg
/app2 # pwd
/app2
Run Code Online (Sandbox Code Playgroud)
安装在哪个位置-v $(pwd):/app2?它不在~/test/dind-volumes主机操作系统上。share是tomita-cfg来自主机操作系统的文件夹,但路径完全不同,甚至不是从~
我遇到了 K8S+DinD 问题:
could not select device driver "nvidia" with capabilities: [[gpu]]完全错误
http://localhost:2375/v1.40/containers/long-hash-string/start: Internal Server Error ("could not select device driver "nvidia" with capabilities: [[gpu]]")
Run Code Online (Sandbox Code Playgroud)
execK8S pod 内的 DinD 映像nvidia-smi不可用。
一些调试,似乎是由于 DinD 缺少 Nvidia-docker-toolkit,当我直接在本地笔记本电脑 docker 上运行相同的作业时,我遇到了相同的错误,我通过安装nvidia-docker2 sudo apt-get install -y nvidia-docker2修复了相同的错误。
我想也许我可以尝试将 nvidia-docker2 安装到 DinD 19.03 (docker:19.03-dind),但不知道该怎么做?通过多阶段 docker 构建?
非常感谢!
更新:
吊舱规格:
spec:
containers:
- name: dind-daemon
image: docker:19.03-dind
Run Code Online (Sandbox Code Playgroud) 我有以下设置
问题是,由于注册表在主机上的端口上运行,因此无法从构建脚本生成的构建库的 docker 容器中的 docker 访问它。我没有找到有关如何在 jenkinsfile 中执行类似 --net="host" (来自 docker run)之类的操作的信息。我想这会起作用吗?
知道如何改进通过节点 docker 容器构建的设置,但能够发布到注册表吗?
我想将一个应用程序部署到 Airflow,该应用程序接受配置文件作为参数,拉取所述配置指定的 git 存储库,然后将其转换为 Docker 映像,然后将该映像上传到 GCP 的 Artifact Registry。在 Airflow DAG 中构建 docker 镜像的最佳实践是什么?
我尝试通过 Airflow 编排手动触发的云构建运行 - 我无法使用 CloudBuildCreateBuildOperator 将必要的替换传递到 cloudbuild.yaml 文件中,也无法指定工作区。
我还创建了一个 docker 映像,它本身可以创建新的 docker 映像(当 docker.sock 文件作为卷安装时)。然而,使用 KubernetesPodOperator 来调用它似乎违背了 Airflow 的设计理念,因为此任务将通过直接在主机上构建新的 docker 镜像来影响主机。
docker docker-build airflow docker-in-docker google-cloud-build
docker-in-docker ×13
docker ×9
kubernetes ×3
gitlab ×2
airflow ×1
alpine-linux ×1
azure-cli ×1
cgroups ×1
docker-build ×1
gitlab-ci ×1
gpu ×1
jenkins ×1
proxy ×1
sbt ×1
scala ×1
spring-boot ×1
verdaccio ×1