首页 > 数据库 >原来Python自带了数据库,用起来真方便

原来Python自带了数据库,用起来真方便

时间:2022-12-10 18:55:39浏览次数:57  
标签:process Python 数据库 access runner entrypoint 自带 Docker image

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.

标签:process,Python,数据库,access,runner,entrypoint,自带,Docker,image
From: https://www.cnblogs.com/sdfasdf/p/16972083.html

相关文章

  • python中数据库查看
    数据读取:1、使用fetchone()方法获取单条数据data=cursor.fetchone()print(data)2、使用fetchall()方法获取多条数据rows=cur.fetchall()forrowinrows:pr......
  • Python模块fileinput操作文件和目录操作总结
    前言之前介绍Python的pathlib模块可以有效的路径及文件查找等方便操作,本篇介绍一个相对readlines()获取文件内容更高效的用法fileinput模块对一个或者多个文件的内容迭......
  • python连接数据库mysql
    前提:电脑已经安装数据库环境1、导入pymysql库2、建立连接:md=pymysql.connect(host='localhost',user='root',password='数据库密码',db='lili')3、新建游标:cur=md......
  • 昨晚停网后,我写了一段Python代码攻破了隔壁老王家的wifi密码
    OverridetheentrypointofanimageIntroducedinGitLabandGitLabRunner9.4.Readmoreaboutthe extendedconfigurationoptions.Beforeexplainingtheav......
  • Django框架2、静态文件配置、form表单、request对象、pycharm链接数据库、django链接
    一、静态文件配置1、静态文件​ 指不经常发生变化的文件,主要针对html文件所使用到的各种资源​ 是前端已经写好了的能够直接调用或者使用的文件都可以称之为静态文件,比......
  • Python正则表达式
    Python正则表达式情况:在一个EXCEL文件中,记录了众多公司的账目,单位有万元和亿元,彼此混杂。现想把单位统一为万元,且不显示出来法一:利用EXCEL的公式=IF(VALUE(MID(B2,1,......
  • Python之装饰器
    1.装饰器简介python的装饰器本质上是一个Python函数,它可以让其他函数在不需要做任何代码变动的前提下增加额外功能,装饰器的返回值也是一个函数对象。简单的说装饰器就是......
  • Django链接数据库 增删改查/配置
    Django静态文件配置服务端需要生成HTML文件,需要一些额外的CSS,JS代码文件以及img图片等,还有一些脚本帮助我们渲染网页页面,在Django中我们可以把这些文件统称为静态文件。......
  • 数据库事务
    事务事务简介数据库的事务(Transaction)是一种机制、一个操作序列,包含了一组数据库的操作命令事务把所有的命令作为一个整体一起向系统提交或者撤销操作请求,即这一组命......
  • Python爬取世界杯热搜榜,并制作脚本自动发送信息到邮箱
    前言现在正是卡塔尔世界杯激战正酣的时候,每天都有各种各样的新闻。而且,不同的球队,随着比赛的进程,关注的热度也会发生翻天覆地的变化。今天我们就来获取卡塔尔世界的球......