chore(kb): add notes about docker image creation in gitlab runners

This commit is contained in:
Michele Cereda
2024-04-16 23:20:29 +02:00
parent 0e8600e3fb
commit 7aecfbf53c
5 changed files with 39 additions and 4 deletions

View File

@@ -70,15 +70,22 @@ buildah config --port '80' 'wc-fedora'
buildah commit 'starting-working-container' 'alpine-custom' buildah commit 'starting-working-container' 'alpine-custom'
buildah commit --rm 'working-container-removed-after-commit' 'oci-archive:/tmp/alpine-custom.tar' buildah commit --rm 'working-container-removed-after-commit' 'oci-archive:/tmp/alpine-custom.tar'
# Create images from Dockerfiles. # Create images.
# The current directory is used as default context path.
buildah build -t 'fedora-http-server' buildah build -t 'fedora-http-server'
buildah build --pull -t '012345678901.dkr.ecr.eu-east-2.amazonaws.com/me/my-alpine:0.0.1' 'dockerfile-dir' buildah build --pull -t '012345678901.dkr.ecr.eu-east-2.amazonaws.com/me/my-alpine:0.0.1' 'dockerfile-dir'
buildah build --manifest 'me/my-alpine:0.0.1' --platform 'linux/amd64,linux/arm64/v8'
buildah build … --output 'type=tar,dest=/tmp/alpine.tar'
# Inspect stuff.
buildah inspect 'fedora-http-server'
buildah inspect -t 'image' 'cfde91e4763f'
buildah manifest inspect 'me/my-alpine:0.0.1'
# Push images. # Push images.
buildah push 'cfde91e4763f' 'docker://registry.example.com/repository:tag' buildah push 'cfde91e4763f' 'docker://registry.example.com/repository:tag'
buildah push --disable-compression 'localhost/test-image' 'docker-daemon:test-image:3.0' buildah push --disable-compression 'localhost/test-image' 'docker-daemon:test-image:3.0'
buildah push --creds 'kevin:secretWord' --sign-by '7425…109F' 'docker.io/library/debian' 'oci:/path/to/layout:image:tag' buildah push --creds 'kevin:secretWord' --sign-by '7425…109F' 'docker.io/library/debian' 'oci:/path/to/layout:image:tag'
buildah manifest push
# Remove working containers. # Remove working containers.
buildah rm 'fedora-http-server' buildah rm 'fedora-http-server'
@@ -126,7 +133,9 @@ buildah rm --all \
- [Tutorial: Use Buildah in a rootless container with GitLab Runner Operator on OpenShift] - [Tutorial: Use Buildah in a rootless container with GitLab Runner Operator on OpenShift]
- [Building container image in AWS CodeBuild with buildah] - [Building container image in AWS CodeBuild with buildah]
- [Building multi-architecture containers with Buildah]
- [Use Buildah to build OCI container images] - [Use Buildah to build OCI container images]
- [Containers-transports man page]
<!-- <!--
References References
@@ -143,5 +152,7 @@ buildah rm --all \
<!-- Others --> <!-- Others -->
[building container image in aws codebuild with buildah]: https://dev.to/leonards/building-container-image-in-aws-codebuild-with-buildah-8gk [building container image in aws codebuild with buildah]: https://dev.to/leonards/building-container-image-in-aws-codebuild-with-buildah-8gk
[building multi-architecture containers with buildah]: https://medium.com/oracledevs/building-multi-architecture-containers-with-buildah-44ed100ec3f3
[containers-transports man page]: https://man.archlinux.org/man/extra/containers-common/containers-transports.5.en
[tutorial: use buildah in a rootless container with gitlab runner operator on openshift]: https://docs.gitlab.com/ee/ci/docker/buildah_rootless_tutorial.html [tutorial: use buildah in a rootless container with gitlab runner operator on openshift]: https://docs.gitlab.com/ee/ci/docker/buildah_rootless_tutorial.html
[use buildah to build oci container images]: https://www.linode.com/docs/guides/using-buildah-oci-images/ [use buildah to build oci container images]: https://www.linode.com/docs/guides/using-buildah-oci-images/

View File

@@ -10,6 +10,11 @@
```sh ```sh
# List and get information about the repositories in ECRs. # List and get information about the repositories in ECRs.
aws ecr describe-repositories aws ecr describe-repositories
aws ecr describe-repositories --repository-names 'docker-tools/image-builder'
aws ecr describe-repositories --registry-id '123456789012' --query 'repositories[].repositoryName'
# Create repositories.
aws ecr create-repository --repository-name 'docker-tools/image-builder'
# List images in ECRs. # List images in ECRs.
aws ecr list-images --repository-name 'repository' aws ecr list-images --repository-name 'repository'
@@ -21,7 +26,7 @@ aws ecr get-login-password \
| docker login --username 'AWS' --password-stdin 'aws_account_id.dkr.ecr.region.amazonaws.com' \ | docker login --username 'AWS' --password-stdin 'aws_account_id.dkr.ecr.region.amazonaws.com' \
# Pull images from ECRs. # Pull images from ECRs.
docker 'pull aws_account_id.dkr.ecr.region.amazonaws.com/repository_name/image_name:tag' docker pull 'aws_account_id.dkr.ecr.region.amazonaws.com/repository_name/image_name:tag'
# List and show pull through cache rules. # List and show pull through cache rules.
@@ -52,6 +57,11 @@ docker pull '123456789012.dkr.ecr.eu-south-1.amazonaws.com/docker-hub/library/ng
docker pull '123456789012.dkr.ecr.us-west-2.amazonaws.com/docker-hub/grafana/grafana' docker pull '123456789012.dkr.ecr.us-west-2.amazonaws.com/docker-hub/grafana/grafana'
``` ```
```sh
aws ecr describe-repositories --repository-names 'docker-tools/image-builder' \
|| aws ecr create-repository --repository-name 'docker-tools/image-builder'
```
## Pull through cache feature ## Pull through cache feature
> **Note:** when requesting an image for the first time using the pull through cache, the ECR creates a new repository for that image.<br> > **Note:** when requesting an image for the first time using the pull through cache, the ECR creates a new repository for that image.<br>

View File

@@ -309,8 +309,10 @@ docker load …
- [Configuring DNS] - [Configuring DNS]
- [Cheatsheet] - [Cheatsheet]
- [Getting around Docker's host network limitation on Mac] - [Getting around Docker's host network limitation on Mac]
- [Dockerfile reference]
- [Building multi-arch images for ARM and x86 with Docker Desktop] - [Building multi-arch images for ARM and x86 with Docker Desktop]
- [OpenContainers Image Spec] - [OpenContainers Image Spec]
- [Docker ARG, ENV and .env - a Complete Guide]
<!-- <!--
References References
@@ -324,11 +326,13 @@ docker load …
<!-- Upstream --> <!-- Upstream -->
[building multi-arch images for arm and x86 with docker desktop]: https://www.docker.com/blog/multi-arch-images/ [building multi-arch images for arm and x86 with docker desktop]: https://www.docker.com/blog/multi-arch-images/
[dockerfile reference]: https://docs.docker.com/reference/dockerfile/
[github]: https://github.com/docker [github]: https://github.com/docker
<!-- Others --> <!-- Others -->
[arch linux wiki]: https://wiki.archlinux.org/index.php/Docker [arch linux wiki]: https://wiki.archlinux.org/index.php/Docker
[cheatsheet]: https://collabnix.com/docker-cheatsheet/ [cheatsheet]: https://collabnix.com/docker-cheatsheet/
[configuring dns]: https://dockerlabs.collabnix.com/intermediate/networking/Configuring_DNS.html [configuring dns]: https://dockerlabs.collabnix.com/intermediate/networking/Configuring_DNS.html
[docker arg, env and .env - a complete guide]: https://vsupalov.com/docker-arg-env-variable-guide/
[getting around docker's host network limitation on mac]: https://medium.com/@lailadahi/getting-around-dockers-host-network-limitation-on-mac-9e4e6bfee44b [getting around docker's host network limitation on mac]: https://medium.com/@lailadahi/getting-around-dockers-host-network-limitation-on-mac-9e4e6bfee44b
[opencontainers image spec]: https://specs.opencontainers.org/image-spec/ [opencontainers image spec]: https://specs.opencontainers.org/image-spec/

View File

@@ -143,6 +143,14 @@ git commit --amend --no-edit --gpg-sign
# Show commits which would be pushed. # Show commits which would be pushed.
git log @{u}.. git log @{u}..
# Get the current commit SHA.
git rev-parse 'HEAD'
git show -s --format=%H
# Get the current commit SHA in short form.
git rev-parse --short 'HEAD'
git show -s --format=%h
# Revert a commit, but keep the history of the event as a separate commit. # Revert a commit, but keep the history of the event as a separate commit.
git revert 'commit_hash' git revert 'commit_hash'
@@ -1003,7 +1011,7 @@ git -c http.sslVerify=false …
- [How to manage your secrets with git-crypt] - [How to manage your secrets with git-crypt]
- Question about [how to rebase a local branch with remote master] - Question about [how to rebase a local branch with remote master]
- Question about how to [merge master into a feature branch] - Question about how to [merge master into a feature branch]
- Question about how to [prune local branches that do not exist on remote anymore] - Question about how to [prune local tracking branches that do not exist on remote anymore]
- Question about how to [rebase remote branches] - Question about how to [rebase remote branches]
- Quick guide about [git rebase][rebase quick guide] - Quick guide about [git rebase][rebase quick guide]
- Quick guide about how to [remove files from git commit] - Quick guide about how to [remove files from git commit]

View File

@@ -548,6 +548,7 @@ Solution: give that user _developer_ access or have somebody else with enough pr
- [Caching in CI/CD] - [Caching in CI/CD]
- [Predefined CI/CD variables reference] - [Predefined CI/CD variables reference]
- [Tutorial: Use Buildah in a rootless container with GitLab Runner Operator on OpenShift] - [Tutorial: Use Buildah in a rootless container with GitLab Runner Operator on OpenShift]
- [Use kaniko to build Docker images]
<!-- <!--
References References
@@ -588,6 +589,7 @@ Solution: give that user _developer_ access or have somebody else with enough pr
[tutorial: use buildah in a rootless container with gitlab runner operator on openshift]: https://docs.gitlab.com/ee/ci/docker/buildah_rootless_tutorial.html [tutorial: use buildah in a rootless container with gitlab runner operator on openshift]: https://docs.gitlab.com/ee/ci/docker/buildah_rootless_tutorial.html
[use ci/cd configuration from other files]: https://docs.gitlab.com/ee/ci/yaml/includes.html [use ci/cd configuration from other files]: https://docs.gitlab.com/ee/ci/yaml/includes.html
[use extends to reuse configuration sections]: https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html#use-extends-to-reuse-configuration-sections [use extends to reuse configuration sections]: https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html#use-extends-to-reuse-configuration-sections
[use kaniko to build docker images]: https://docs.gitlab.com/ee/ci/docker/using_kaniko.html
<!-- Others --> <!-- Others -->
[authenticating your gitlab ci runner to an aws ecr registry using amazon ecr docker credential helper]: https://faun.pub/authenticating-your-gitlab-ci-runner-to-an-aws-ecr-registry-using-amazon-ecr-docker-credential-b4604a9391eb [authenticating your gitlab ci runner to an aws ecr registry using amazon ecr docker credential helper]: https://faun.pub/authenticating-your-gitlab-ci-runner-to-an-aws-ecr-registry-using-amazon-ecr-docker-credential-b4604a9391eb