Menu
blog.headdesk.me
blog.headdesk.me

Automate docker image build and push

Posted on 2020/04/292021/07/25

I’m experimenting with Jenkins and I’m starting to like it. In this page, I’m going to demonstrate how to configure Jenkins to build docker image and push it to my registry automatically.

What you’ll need:

  • A git repository storing the Dockerfile
  • A docker registry to push the image to
  • A machine with Jenkins installed
  • Jenkins needs the git and Docker plugins

On Jenkins console, create a project. For example, amzn2-awscli2. In the Source Code Management section, configure Jenkins to pull from my git repo. In this example, the repo is on https://xpk.headdesk.me/git/xpk/amzn2-awscli2.git and it’s public so no credential required.

In the build trigger section, enable Build periodically and tell Jenkins to perform the build weekly. The dockerfile itself does not change frequently. Otherwise a git webhook would be preferred. I still want the build to happen regularly to keep my awscli current.

In the build section, tell Jenkins where to push the image and what to name it. In this case, it’s registry.one27.cf/amzn2-awscli2

Finally, in the Post-build section, tell Jenkins to clean up the workspace after build.

Click build now in this project and after a few minutes, the image is built and pushed to my registry.

It’s a minimalist demonstration. I’m still learning about Jenkins. Comments are welcomed.

facebookShare on Facebook
TwitterTweet

Full text search

Recent Posts

  • Dumping AWS Organization tree
  • Free is the most expensive
  • Terraform conditional resource and blocks
  • Upgrade Ubuntu 16.04 to latest release
  • Inspect and control network traffic on AWS
  • aws (8)
  • coffee (1)
  • headfi (1)
  • linux (7)
  • others (55)
  • security (2)
  • tech (36)
  • wordpress (2)

apache aws awscli azure backup cloud coffee coreos distributed filesystem docker ec2 EL8 elasticcache etckeeper featured heartbleed kernel linux mail meltdown mysql php pine python rdp rds Redhat Red Hat RHEL RHEL7 rpm Ryzen snapshot spectre SSL systemd tech terraform ubuntu ubuntu upgrade vector vpn wordpress xtreemfs yum

©2022 blog.headdesk.me | Powered by SuperbThemes & WordPress