Build & Use Custom Docker images in your GitLab CI/CD pipeline

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 มิ.ย. 2024
  • The public images from Dockerhub don't always contain all the dependencies you need. So instead of adding a lot of commands to your pipeline, I will show you how easy it is to build a custom Docker image with all the dependencies you need, push it to the GitLab Container Registry and use it in your pipeline.
    --
    ⭐️ 🎓 GitLab CI/CD ONLINE COURSE ⭐️
    Want to learn more about CI/CD pipelines? Check my GitLab CI online course.
    Get it at a special price and help support this TH-cam channel:
    www.vdespa.com/courses
    --
    ⭐️ 💬 I have a question. ⭐️
    I do my best to answer all comments here on TH-cam but I cannot make any guarantees.
    If you are asking a question, make sure to include as many details as possible.
    --
    ⭐️ 💡 I have a video idea ⭐️
    Do you want me to create a video on a specific topic? Just fill out the form below:
    forms.gle/uWEzXFQ2viJtZtvZ7
    --
    ⭐️ 📺 Learn GitLab on TH-cam ⭐️
    Collection of video tutorials:
    ▸ Learn GitLab CI:
    • Gitlab
    ___
    ⭐️ 📕 Free resources ⭐️
    📌 Official Gitlab CI documentation
    docs.gitlab.com/
    📌 DevOps with Valentine
    / devops-with
    --
    ⭐️ 📩 Contact & Imprint ⭐️
    👉 Follow me on Twitter:
    / vdespa
    👉 Follow me on Medium:
    / vdespa
    👉 Follow me on Facebook:
    / valentin-despa-1130381...
    👉 Let's connect on LinkedIn:
    / vdespa
    vdespa.com/imprint
    #gitlab #docker
    __

ความคิดเห็น • 49

  • @vdespa
    @vdespa  2 ปีที่แล้ว +3

    Want to have ME be your GitLab & DevOps teacher? 🤔
    Here's how: vdespa.com/courses/

  • @danielmuranyi3556
    @danielmuranyi3556 ปีที่แล้ว +2

    Hey Valentin! I have only two subscriptions, one is for Dave2D and one for you. This is what I am looking for, I already bought one of you Udemy course to dig deeper in GitLab. Thanks for the great instructions and the very clarified description. I am trying to learn as much as I can beside my 5 days old second son :D

    • @vdespa
      @vdespa  ปีที่แล้ว

      I appreciate that, Daniel. Thank you! Take it easy with learning, make it fun, not a burden ;)

  • @opensourceaarsaan6759
    @opensourceaarsaan6759 2 ปีที่แล้ว +1

    cool & perfect
    Thanks a lot

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      You are welcome. Thank you for leaving a comment.

  • @wajidshaikh5619
    @wajidshaikh5619 2 ปีที่แล้ว

    Good one ,, can we see from scratch about git and there setup with Linux machine and how and where image and containers going to

  • @raphaelpereira1503
    @raphaelpereira1503 9 หลายเดือนก่อน

    AMAZING CI/CD tutorial, but just to make it the best ever a link to the repo would be great.

    • @vdespa
      @vdespa  9 หลายเดือนก่อน

      You are welcome. Thank you for leaving a comment.

  • @KVS797
    @KVS797 2 ปีที่แล้ว

    I think this part should be in your CI/CD udemy course with deploying this image

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      Thanks for your suggestion. I am expanding the course to include Docker as well.

  • @hwy9nightkid
    @hwy9nightkid 2 ปีที่แล้ว

    I personally understand the thought that its bad practice to use latest.. but IMO.. it needs to be tested somewhere.. and for my personal proejcts I set latest.. so that at any time if something does break.. I find out about it right away.. otherwise things just run smoothly.. but I get in a job site that might not be tolerable to others

  • @ha3anabedi457
    @ha3anabedi457 2 ปีที่แล้ว

    it's great thanks you

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      You are welcome!

  • @omerguzel8351
    @omerguzel8351 ปีที่แล้ว

    I adjust an image that have all dependencies inside of it. Is this the nearest or the exact process that I should do? I only need gitlab runner to fetch image from local not from docker hub but I couldn't find a way and this tutorial is similar to what I wanted. Am I wrong?

  • @premierde
    @premierde 3 หลายเดือนก่อน

    Can you show how to use Kaniko, Buildah, Podman

  • @RuiDuartept
    @RuiDuartept 2 ปีที่แล้ว +3

    Nice video, thanks for you work!
    Would you be able to create a tutorial for building your own docker images locally?

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      Thanks. You can use the same commands I have shown you locally as well.

  • @Invisileflyingdog
    @Invisileflyingdog 4 หลายเดือนก่อน

    I have build a docker image locally and push it to a registry that can be reached publicly (needed sign in ofc), but whenever I tried to use this image from gitlab runner after the before script to sign in it alwasys complianed the image pull failure..

  • @erikwhitesides
    @erikwhitesides 2 ปีที่แล้ว

    on my personal gitlab instance i had to register the gitlab runner with the shell executor,
    then i had to use docker:20.10.10-dind for image

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      If you are using a shell executor, any image you specify in your pipeline config is ignored.

  • @EnderCrypt
    @EnderCrypt ปีที่แล้ว

    oh... your title is kinda easy to missunderstand, i was looking for a way to
    "Build & Use Custom Docker images in your GitLab CI/CD pipeline"
    specifically i want to BUILD images, from INSIDE the gitlab CI/CD pipeline
    do you by any chance have any solution for this?

  • @firo1934
    @firo1934 ปีที่แล้ว

    What is advantage of creating and using a yaml ci build file over a Dockerfile to create your image?

    • @wgray8231
      @wgray8231 ปีที่แล้ว

      you still use a Dockerfile -- this CI yaml just gives the gitlab runner the instructions on executing docker build

  • @teeesen
    @teeesen 2 ปีที่แล้ว

    Why build the Docker image on a schedule? Won’t it just build and push the same thing as it did the previous day if the Dockerfile hasn’t changed. And, if the Dockerfile has changed, wouldn’t you want to build a new image right away? Also, does it make sense to create and use a new tag each time the Dockerfile changes?

    • @vdespa
      @vdespa  2 ปีที่แล้ว +1

      Good points. Well, it depends. What if you don't use a tag in your base image?
      But yes, using tags makes sense.

  • @lorenzorava7511
    @lorenzorava7511 2 ปีที่แล้ว +1

    how did you handle the pull policy? if it is "if-not-present" the job never pull again your new image, but it will take always the previous...

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      Good point. The safest way is to use tags.

    • @lorenzorava7511
      @lorenzorava7511 2 ปีที่แล้ว

      @@vdespa mm, difficult to automate in this case. You should change the tag manually in some point...

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      @@lorenzorava7511 I mean there is not single solution for all problems. You need to test different options and see what works for you.

  • @MilMike
    @MilMike 4 หลายเดือนก่อน

    how can I use my custom image as a base image in my Dockerfile?
    For example, my base image has all the dependencies and I want to use it to build my project. Is this possible? I tried to use it like so but it doesn't work:
    FROM /myuser/myproject/base:v1.0.0
    any ideas?

  • @TheMaurober
    @TheMaurober ปีที่แล้ว

    Thanks for the video. I run this code to create a custom docker image but i get an error saying:
    Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?
    Any idea how can I solve this problem? I already set tls=false but still not working

    • @vdespa
      @vdespa  ปีที่แล้ว

      Hey Mauro, are you using the shared runners from GitLab.com or are you self-hosting...?

    • @TheMaurober
      @TheMaurober ปีที่แล้ว

      @@vdespa hi, I'm using self-hosted

    • @vdespa
      @vdespa  ปีที่แล้ว +1

      @@TheMaurober Please see the Troubleshooting part of this article. medium.com/p/b63b91a58728

    • @TheMaurober
      @TheMaurober ปีที่แล้ว

      @@vdespa Thanks!!

  • @hwy9nightkid
    @hwy9nightkid 2 ปีที่แล้ว

    I got your setup but.. when i go to apt install anything it says source not found? using ubuntu:20.04 it cannot find things as simple as apt install python3 .. I will go to the gitlab community next to see what I missed.. thanks for the great video tho to kick start my efforts

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      I suggest taking an image that already has python.

  • @sebastiangehteuchnixan42
    @sebastiangehteuchnixan42 ปีที่แล้ว

    What if I have a docker-compose file ?
    "docker-compose build -t $CI_REGISTRY_IMAGE ." does not work
    How can I tag docker-compose ?

  • @zembelallan5768
    @zembelallan5768 2 ปีที่แล้ว

    I want to push a Java image to ECR, then how to make a CD?

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      For ECR, please watch this tutorial: th-cam.com/video/jg9sUceyGaQ/w-d-xo.html

  • @user-ip5cn6mb9e
    @user-ip5cn6mb9e 8 หลายเดือนก่อน +1

    you did the build... but not the use...

  • @makondoo
    @makondoo 11 หลายเดือนก่อน

    i am impressed how bad and unclear this video is

    • @vdespa
      @vdespa  11 หลายเดือนก่อน

      Let me know if you have any questions and what is unclear?

  • @omarsh5269
    @omarsh5269 2 ปีที่แล้ว

    Thanks for the video! I am having this issue
    Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      Try using the shared runners from GitLab.com

  • @ngocthiennguyen3318
    @ngocthiennguyen3318 ปีที่แล้ว

    when i'm login, message return
    error during connect: Post "docker:2375/v1.24/auth": dial tcp: lookup docker on 8.8.8.8:53: no such host

  • @bossdarkkiller
    @bossdarkkiller ปีที่แล้ว

    I get this error: "error during connect: Post "docker:2375/v1.24/auth": dial tcp: lookup docker on **:53: no such host" ---- Anyone know the solution?

    • @mariobuser6656
      @mariobuser6656 ปีที่แล้ว

      Dito. Would also be interested in a solution.

    • @DeadlyDragon_
      @DeadlyDragon_ ปีที่แล้ว

      you need to use tcp:// not http its not a web server