Skip to content

Podman

4 posts with the tag “Podman”

GitLab CI-CD Push to Repository

On gitlab-runner push changes to repository.

We assume that accessing repository with HTTPS method.

1. Add Personal Access Token (PAT) for Project

Section titled “1. Add Personal Access Token (PAT) for Project”

Ensure this token have the authority write_repository.

We assume that the variable name is GITLAB_PRIVATE_TOKEN, and value is the token created in first step.

Update git url with proper authority: git remote set-url origin "https://${GITLAB_PRIVATE_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git"

The .gitlab-ci.yml looks like:

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-Configuration

GitLab CI-CD with GitLab-Runner

Run GitLab-Runner in container for GitLab CI/CD.

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

Config the runner with instructions.

[1]. https://docs.gitlab.com/runner/

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

[3]. Podman-Volumes-and-SELinux

[4]. Manage-Podman-Container-With-Systemd

Some Operations After Installing Docker and Podman

After installing Docker, there are usually a few follow-up tasks to complete. This note provides an all-in-one reference.

Add the current user to the docker group:

cat /etc/group | grep docker # Check whether the docker group exists
groups # List your user groups and confirm whether you are in the docker group
# If the docker group does not exist, create it:
sudo groupadd docker
# Add the current user to the docker group
sudo gpasswd -a ${USER} docker
# Restart the service
sudo service docker restart
# Switch groups to refresh the cached group list
newgrp - docker;
# Run the commands line by line. In some cases, the second command does not take effect when both are run in a batch.
newgrp - `groups ${USER} | cut -d' ' -f1`;
# Alternatively, log out and log back in
pkill X

Create or edit /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"
]
}
  • You can replace these mirrors with other available registry mirror addresses.

(2). Configure Podman registry acceleration

Section titled “(2). Configure Podman registry acceleration”

Edit /etc/containers/registries.conf and use the following pattern:

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

3. Change Docker’s default storage location

Section titled “3. Change Docker’s default storage location”

sudo systemctl stop docker

(2). Move the data directory to the target location

Section titled “(2). Move the data directory to the target location”

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

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

sudo systemctl restart docker

Docker official China mirror: https://registry.docker-cn.com

NetEase: http://hub-mirror.c.163.com

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

Alibaba Cloud: http://<your 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 .

  • For docker, just replacepodmanwithdocker.

podman build --platform=linux/arm/v7 -t TAGS . Here we takearm/v7as an example.

3. Push the Image to DockerHubUse the following command, replacingusernameandpasswordwith your actual username and password```

Section titled “3. Push the Image to DockerHubUse the following command, replacingusernameandpasswordwith your actual username and password```”

podman push –creds username:password
docker.io/library/IMAGENAME:latest
docker.io://ACCOUNT/IMAGENAME:latest

## 4. Push after Login```
podman login docker.io
podman push docker.io/library/IMAGENAME:latest

[2]. Container-On-Mikrotik