首页 > 编程语言 >Python对json的操作总结

Python对json的操作总结

时间:2022-12-09 12:33:49浏览次数:63  
标签:总结 container Python image access runner json 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,Python,image,access,runner,json,entrypoint,Docker
From: https://www.cnblogs.com/sdfasdf/p/16968583.html

相关文章

  • json的使用(对象转字符串、字符串转对象)以及具体的使用(结合ajax使用)
    为了方便地处理JSON数据,JSON提供了json.js包,​​下载地址​​​注意:GSON为json的升级版,更容易使用,​​下载地址​​JSON结构有两种结构:json简单说就是javascript中的对象......
  • [python]Anaconda介绍、安装及使用
    一、什么是Anaconda?简介Anaconda(​​官方网站​​)就是可以便捷获取包且对包能够进行管理,同时对环境可以统一管理的发行版本。Anaconda包含了conda、Python在内的超过180个科......
  • python基础-模块和包
    1.什么是python的包  包就是一个文件夹,里面放着一个个py文件或子包;  在包中可以被调用的一个个py文件,我们叫做模块;    如上,test就是一个包、two.py就是test下......
  • PYTHON 异常处理
    1.1异常处理有时可将程序错误(Error)称作程序异常(Exception)。出现错误程序终止。出现异常程序终止,也可以捕捉异常和撰写异常处理程序,处理完程序可以继续运行。1.1......
  • python中os.system(cmd)函数的返回值:python中的os.system(cmd)的返回值与linux命令返
    前言①在实际开发过程中,经常会遇到在Python代码中调用shell脚本,再获取脚本返回的返回值的情况: os.system(cmd) ②由于系统环境的问题, os.system(cmd) 函数执行命令后......
  • Python基础语法
    1.continue语句#!/usr/bin/python#-*-coding:UTF-8-*-n=100whilen>0:n-=1ifn%2==0:continueprint(n)#n-......
  • JVM 调优总结
    1.通过调整堆中新生代和幸存代大小,避免因为幸存代不足而让MinorGC后的对象进入老年代。每次MinorGC都有对象进入老年代会造成数次MinorGC后FullGC.2.减少永久区浪......
  • 基于Python+Django+Vue+MYSQL的社团管理系统
    OverridetheentrypointofanimageIntroducedinGitLabandGitLabRunner9.4.Readmoreaboutthe extendedconfigurationoptions.Beforeexplainingtheav......
  • 【推荐收藏】Python 常见报错以及解决方案
    OverridetheentrypointofanimageIntroducedinGitLabandGitLabRunner9.4.Readmoreaboutthe extendedconfigurationoptions.Beforeexplainingtheav......
  • [python] ThreadPoolExecutor线程池
    初识Python中已经有了threading模块,为什么还需要线程池呢,线程池又是什么东西呢?在介绍线程同步的信号量机制的时候,举得例子是爬虫的例子,需要控制同时爬取的线程数,例子中......