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
__
Want to have ME be your GitLab & DevOps teacher? 🤔
Here's how: vdespa.com/courses/
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
I appreciate that, Daniel. Thank you! Take it easy with learning, make it fun, not a burden ;)
cool & perfect
Thanks a lot
You are welcome. Thank you for leaving a comment.
Good one ,, can we see from scratch about git and there setup with Linux machine and how and where image and containers going to
AMAZING CI/CD tutorial, but just to make it the best ever a link to the repo would be great.
You are welcome. Thank you for leaving a comment.
I think this part should be in your CI/CD udemy course with deploying this image
Thanks for your suggestion. I am expanding the course to include Docker as well.
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
it's great thanks you
You are welcome!
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?
Can you show how to use Kaniko, Buildah, Podman
Nice video, thanks for you work!
Would you be able to create a tutorial for building your own docker images locally?
Thanks. You can use the same commands I have shown you locally as well.
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..
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
If you are using a shell executor, any image you specify in your pipeline config is ignored.
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?
What is advantage of creating and using a yaml ci build file over a Dockerfile to create your image?
you still use a Dockerfile -- this CI yaml just gives the gitlab runner the instructions on executing docker build
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?
Good points. Well, it depends. What if you don't use a tag in your base image?
But yes, using tags makes sense.
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...
Good point. The safest way is to use tags.
@@vdespa mm, difficult to automate in this case. You should change the tag manually in some point...
@@lorenzorava7511 I mean there is not single solution for all problems. You need to test different options and see what works for you.
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?
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
Hey Mauro, are you using the shared runners from GitLab.com or are you self-hosting...?
@@vdespa hi, I'm using self-hosted
@@TheMaurober Please see the Troubleshooting part of this article. medium.com/p/b63b91a58728
@@vdespa Thanks!!
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
I suggest taking an image that already has python.
What if I have a docker-compose file ?
"docker-compose build -t $CI_REGISTRY_IMAGE ." does not work
How can I tag docker-compose ?
I want to push a Java image to ECR, then how to make a CD?
For ECR, please watch this tutorial: th-cam.com/video/jg9sUceyGaQ/w-d-xo.html
you did the build... but not the use...
i am impressed how bad and unclear this video is
Let me know if you have any questions and what is unclear?
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?
Try using the shared runners from GitLab.com
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
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?
Dito. Would also be interested in a solution.
you need to use tcp:// not http its not a web server