跳转到内容

Podman

4 posts with the tag “Podman”

GitLab CI-CD 推送到存储库

在 gitlab-runner 上将更改推送到存储库。 我们假设使用HTTPS方法访问存储库。

1.为项目添加个人访问令牌(PAT)确保此令牌具有权限write_repository。

Section titled “1.为项目添加个人访问令牌(PAT)确保此令牌具有权限write_repository。”

2. 将变量添加到项目中我们假设变量名称是GITLAB_PRIVATE_TOKEN,值是第一步创建的令牌。

Section titled “2. 将变量添加到项目中我们假设变量名称是GITLAB_PRIVATE_TOKEN,值是第一步创建的令牌。”

3. 构建您的.gitlab-ci.yml使用适当的权限更新 git url:git remote set-url origin "https://${GITLAB_PRIVATE_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git"

Section titled “3. 构建您的.gitlab-ci.yml使用适当的权限更新 git url:git remote set-url origin "https://${GITLAB_PRIVATE_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git"”

.gitlab-ci.yml看起来像:

stages:
- build
- deploy
build:
stage: build
script:
- echo "Building your application..."
deploy:
stage: deploy
before_script:
- git remote set-url origin "https://${GITLAB_PRIVATE_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git"
script:
- echo "Deploying your application..."
- git add .
- git commit -m "Automated commit by GitLab CI/CD"
- git push origin

[1]. GitLab-CI-CD-with-GitLab-Runner [2]. Git 配置

带有 GitLab-Runner 的 GitLab CI-CD

在 GitLab CI/CD 的容器中运行 GitLab-Runner。

podman run –detach
–privileged
–name gitlab-runner
–network host
-v ${PWD}/config:/etc/gitlab-runner:z
docker.io/gitlab/gitlab-runner:latest

## 2.在容器中注册Runner```
podman exec -it gitlab-runner gitlab-runner register

按照说明配置跑步者。

[2]. https://zhuanlan.zhihu.com/p/385110311

[3]. Podman-Volume-和-SELinux [4]. 使用 Systemd 管理 Podman 容器

安装 Docker 和 Podman 后的一些操作

Docker安装之后总会有一些操作,这里提供一个AIO解决方案。

加用户到 docker 用户组

cat /etc/group | grep docker # 查找 docker 组,确认其是否存在
groups # 列出自己的用户组,确认自己在不在 docker 组中
# 如果 docker 组不存在,则添加之:
sudo groupadd docker
# 将当前用户添加到 docker 组
sudo gpasswd -a ${USER} docker
# 重启服务
sudo service docker restart
# 切换一下用户组(刷新缓存)
newgrp - docker;
# 必须逐行执行,不知道为什么,批量执行时第二条不会生效
newgrp - `groups ${USER} | cut -d' ' -f1`;
# 或者,注销并重新登录
pkill X

创建或修改 /etc/docker/daemon.json:

{
"registry-mirrors": [
"https://1nj0zren.mirror.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn",
"http://f1361db2.m.daocloud.io",
"https://registry.docker-cn.com"
]
}
  • 镜像地址可以换成其他的

修改文件/etc/containers/registries.conf 修改为以下内容:

[[registry]]
prefix = "docker.io"
location = "xxxxxxxx.mirror.aliyuncs.com"

sudo systemctl stop docker

mv /var/lib/docker/ /home/dockerdata

ln -s /home/dockerdata/ /var/lib/docker

sudo systemctl restart docker

docker官方中国区 https://registry.docker-cn.com

网易 http://hub-mirror.c.163.com

USTC http://docker.mirrors.ustc.edu.cn

阿里云 http://<你的ID>.mirror.aliyuncs.com

[1].http://www.markjour.com/article/docker-no-root.html

[2].https://juejin.cn/post/6844903840303546376

[3].https://blog.csdn.net/glongljl/article/details/80158297

[4].https://blog.csdn.net/qq_21933797/article/details/115186907

Build Container Image with Podman

使用命令

podman build -t TAGS .

  • 对于docker,只需要将podman换成docker。

使用命令

podman build --platform=linux/arm/v7 -t TAGS .

此处以arm/v7为例。

使用下列命令,将username和password替换为实际的用户名和密码

podman push --creds username:password \
docker.io/library/IMAGENAME:latest \
docker.io://ACCOUNT/IMAGENAME:latest
podman login docker.io
podman push docker.io/library/IMAGENAME:latest

[1]. Some-Operations-After-Installing-docker-and-podman

[2]. Container-On-Mikrotik