首页 > 其他分享 >前端入门学习笔记四十六

前端入门学习笔记四十六

时间:2022-12-10 04:44:05浏览次数:54  
标签:container 入门 runner image 笔记 access entrypoint Docker 四十六

Override the entrypoint of an image

Introduced in GitLab and GitLab Runner 9.4. Read more about the extended configuration options.

Before explaining the available entrypoint override methods, let’s describe how the runner starts. It uses a Docker image for the containers used in the CI/CD jobs:

  1. The runner starts a Docker container using the defined entrypoint. The default from Dockerfile that may be overridden in the .gitlab-ci.yml file.
  2. The runner attaches itself to a running container.
  3. The runner prepares a script (the combination of before_scriptscript, and after_script).
  4. The runner sends the script to the container’s shell stdin and receives the output.

To override the entrypoint of a Docker image, define an empty entrypoint in the .gitlab-ci.yml file, so the runner does not start a useless shell layer. However, that does not work for all Docker versions.

  • For Docker 17.06 and later, the entrypoint can be set to an empty value.
  • For Docker 17.03 and earlier, the entrypoint can be set to /bin/sh -c/bin/bash -c, or an equivalent shell available in the image.

The syntax of image:entrypoint is similar to Dockerfile’s ENTRYPOINT.

Let’s assume you have a super/sql:experimental image with a SQL database in it. You want to use it as a base image for your job because you want to execute some tests with this database binary. Let’s also assume that this image is configured with /usr/bin/super-sql run as an entrypoint. When the container starts without additional options, it runs the database’s process. The runner expects that the image has no entrypoint or that the entrypoint is prepared to start a shell command.

With the extended Docker configuration options, instead of:

  • Creating your own image based on super/sql:experimental.
  • Setting the ENTRYPOINT to a shell.
  • Using the new image in your CI job.

You can now define an entrypoint in the .gitlab-ci.yml file.

For Docker 17.06 and later:

image:
  name: super/sql:experimental
  entrypoint: [""]

For Docker 17.03 and earlier:

image:
  name: super/sql:experimental
  entrypoint: ["/bin/sh", "-c"]

Define image and services in config.toml

Look for the [runners.docker] section:

[runners.docker]
  image = "ruby:latest"
  services = ["mysql:latest", "postgres:latest"]

The image and services defined this way are added to all jobs run by that runner.

Access an image from a private Container Registry

To access private container registries, the GitLab Runner process can use:

To define which option should be used, the runner process reads the configuration in this order:

  • DOCKER_AUTH_CONFIG CI/CD variable.
  • DOCKER_AUTH_CONFIG environment variable set in the runner’s config.toml file.
  • config.json file in $HOME/.docker directory of the user running the process. If the --user flag is provided to run the child processes as unprivileged user, the home directory of the main runner process user is used.

Requirements and limitations

  • Available for Kubernetes executor in GitLab Runner 13.1 and later.
  • Credentials Store and Credential Helpers require binaries to be added to the GitLab Runner $PATH, and require access to do so. Therefore, these features are not available on shared runners, or any other runner where the user does not have access to the environment where the runner is installed.

Use statically-defined credentials

There are two approaches that you can take to access a private registry. Both require setting the CI/CD variable DOCKER_AUTH_CONFIG with appropriate authentication information.

  1. Per-job: To configure one job to access a private registry, add DOCKER_AUTH_CONFIG as a CI/CD variable.
  2. Per-runner: To configure a runner so all its jobs can access a private registry, add DOCKER_AUTH_CONFIG as an environment variable in the runner’s configuration.

标签:container,入门,runner,image,笔记,access,entrypoint,Docker,四十六
From: https://www.cnblogs.com/sdfasdf/p/16970710.html

相关文章

  • 前端入门学习笔记四十
    OverridetheentrypointofanimageIntroducedinGitLabandGitLabRunner9.4.Readmoreaboutthe extendedconfigurationoptions.Beforeexplainingtheav......
  • 前端入门学习笔记四十四
    OverridetheentrypointofanimageIntroducedinGitLabandGitLabRunner9.4.Readmoreaboutthe extendedconfigurationoptions.Beforeexplainingtheav......
  • C++ Primer学习笔记 - 第17章 标准库特殊设施(正则表达式)
    目录17.3正则表达式17.3.1使用正则表达式17.3.2匹配与Regex迭代器类型17.3.3使用子表达式17.3.4使用regex_replace17.3正则表达式正则表达式(regularexpression)是......
  • 导数学习笔记
    本来这周一就该写的,但是班里有水痘隔离去不了机房,于是作罢,现在补上。12.5今天发了好像是选修二的教材的一部分,赫然写着“导数”二字,大受震撼。下发的时候老师说了句“......
  • 全整数计算几何入门
    我也正在入,开始写可能得等到期末过后。目前可能能整到全整数半平面交orV图,但是还没写,先gugugu。基础定义:类名成员含义点vec2intx,y;$(x,y)$向量$(0,0......
  • 51单片机-案例程序源码-笔记
    最近整了块单片机,这里分享一下源码,供师兄弟们一起学习研究。如果会c语言的话,可能觉得这些代码实在是太简单了,而且不够优雅......
  • MarkDown 入门学习总结教程
    Webelievethatwritingisaboutcontent,aboutwhatyouwanttosay–notaboutfancyformatting.译文:我们坚信写作写的是内容,所思所想,而不是花样格式.Markdo......
  • 算法学习笔记(3)——二分
    二分二分法用于解决这样一类问题:一个区间能分成左右两部分,左半部分满足性质\(A\),右半部分不满足性质\(A\)。问题的目标是求解这两部分的分界点。所以二分法和区间里有......
  • 算法学习笔记(4)——高精度
    高精度高精度高精度加法高精度减法高精度乘法高精度除法高精度加法题目链接:AcWing791.高精度加法题目描述给定两个正整数(不含前导0),计算它们的和。输入......
  • 算法学习笔记(5)——前缀和与差分
    前缀和与差分前缀和与差分一维前缀和差分一维前缀和前缀和可以用于快速计算一个序列的区间和,也有很多问题里不是直接用前缀和,但是借用了前缀和的思想。用\(s[i......