Learn Docker in 7 Easy Steps - Full Beginner's Tutorial
VloĆŸit
- Äas pĆidĂĄn 16. 05. 2024
- A complete introduction to Docker. Learn how to Dockerize a Node.js and run manage multiple containers with Docker Compose. fireship.io/lessons/docker-ba...
00:00 What is Docker?
01:54 Installation & Tooling
02:40 Dockerfile
06:06 Build an Image
07:12 Run a Container
08:52 Debugging
09:35 Docker Compose
Source code github.com/fireship-io/firesh...
Official Docker www.docker.com
#LearnToCode #Docker
Install the quiz app đ€
iOS itunes.apple.com/us/app/fires...
Android play.google.com/store/apps/de...
Upgrade to Fireship PRO at fireship.io/pro
Use code lORhwXd2 for 25% off your first payment.
My VS Code Theme
- Atom One Dark
- vscode-icons
- Fira Code Font - VÄda a technologie
This video solved my sleep schedule and my social life thx man, now i can talk to my gf about dockerizing our relationship
Probably should. That way, it works on both your systems.
.. just don't forget to expose the right port, so that you can connect to it from your machine ..
Best comment đ
He had us in the first half ngl
ill wait for the kubern8 to fix my loneliness
the way you pronounced "docker ps" was hilarious đđ
I will most probably never forget that command in my life because of how he pronounced it.
*mispronounced
For once i think i heard piss.
went back so I don't miss LOL
2:10
"Docker is a way to package software so it can run on any hardware" better and simpler definition than in the official docs. I love how you simplify complex concepts and pack tons of valuable info into such a short time. Thanks!
Actually, you can't run docker even in the same architecture but a different OS. Since most of the time the production environment will be linux (and docker actually requires some Linux features to work) then locally you either use Linux or use a Linux VM (docker desktop handles the VM under the hood, which nowadays is implemented using WSL on windows and a native hypervisor on Mac).
A more accurate statement would be "docker is a way to package your applications so that they run on a predictable, isolated environment with all their dependencies available"
@avfr My pleasure!
â@@kebien6020 Docker desktop is just the GUI. The Docker engine is what handles containers and it runs a VM of linux. But you don't need to do anything different on a Mac or Windows than you would on a Linux host, it's the same experience to any host that can install and run docker engine.
@@lasysk I just checked on the official docs and no, Docker Engine is not responsible for running any kind of virtualization.
But that's just terminology. Your point stands that from a developer's point of view nothing changes...
Except performance is worse when not running natively.
...And bind mounts have a really high performance penalty on windows and mac, whereas they are even a performance boost on linux (as compared to the writable layer of the container).
...And mounting unix domain sockets to the host doesn't work.
...And host networking doesn't work either.
...And you can't see /var/lib/docker (useful for educative purposes).
...And when you build an image the build context has to be transferred over the socket, which is slower
@@kebien6020 cool. Can you teach me?
"The leading cause of imposter syndrome among developers is not knowing docker"
You had me in the first 4 seconds. This hits too close to home
@randomguy9777 don't be sus about yourself.
Just start using it for small commits, if you don't remember commands us inbuilt vscode feature, whatever you do webdev - frontend or backend react native or flutter, unity or unreal just start using it.
The thing about git is you don't learn it, you just get better in it.
You can replace docker with any DevOps tech in this sentence and it holds
@@thatsalot3577 dude he is talking about docker not got. Lol almost every half decent Dev knows git.
Oh I see your commnet was probably for someone else
Devs before docker: "It works on my system"
"Then ship your system"
and now: "It works in my container"
I actually told this to my Pm today đđ€Ł
"cool, so we can put your laptop in server room and host our project"
Now : strange it runs on dev just fine.
@Fireship AMAZING VIDEO. I summarized what I learned here:
# What is Docker?
* away to package software to that it runs on any system.
* Docker helps us run our software on any machine by reproducing environments
* Install the software and make sure your command line is working
* Make sure to also install the docker extension for your editor
# Three fundamentals for understanding containers
* Dockerfile: a blueprint for building a docker image
* Create your environment with a docker file
* Docker Image (image): a template for running docker containers
* Images are uploaded to the cloud in registries
* One image file can be used to spawn many containers
* Images are saved in layers: start with a node image, add dependencies, add code...etc.
* Note that images are cached between runs if nothing changes. Hence it is important to list the image of the dependencies before code so that they are cached.
* Container: a running process or application based on an image
# Important commands to master
* docker ps
* Lists all current **running** containers on the system
## Dockerfile
* Create a Dockerfile (mind the spelling and no extension)
Add the instructions you want to be used to create an image:
* FROM: starting image to build the first layer of the container
* EXAMPLE: FROM ubuntu (no node) // FROM node:12 (already configured with node)
* WORKDIR: specify which directory has your code (like a CD into a directory)
* WORKDIR /app
* COPY: copies a file FROM a location in your source to the ROOT of the OS
* COPY package*.jso ./
* RUN: runs a command in the terminal! Uses SHELL FORM (terminal style)
* RUN npm install
* COPY . . (copy all our source code and your NODE_MODULES!! (see next step for solution))
* Adding a .dockerignore file to your root helps you avoid copying your node_modules to your image
* ENV: sets an environment variable
* ENV PORT=8080
* EXPOSE: exposes a port publicly
* CMD: can only be run once per container. Should be written in EXEC FORM (Array Style):
* CMD ["node", "start"]
# Building your image
In a terminal, run:
* docker build: builds an image with (-t) tag name:
* docker build -t {username}/{imagename}:{versionNumber} {path}
* This then will go through the dockerfile and do the steps we've listed
* Then you can use: docker push (to push to an online registry)
# Running your image into a container
* docker run {imageId} or docker run {imageTagName}
* To enable your EXPOSE command to work, use port forwarding:
* docker run -p 5000:8080 //map port 5000 on your machine to 8080 in the container
* Containers keep on running even after you close the terminal. You need to stop them with docker itself
* Note that when you stop a container all the data inside of it is lost.
* If you need to keep the data, you need to use VOLUMES
# Volumes
* a dedicated folder on the host machine
* used to store files to be used later using remounting
* docker volume create shared-stuff
* --mount source=shared-stuff, target=/stuff
# Debugging
* use:
docker desktop
docker exec
* See logs, files...etc
# Performance Tips
* Use a microservices architecture
* Run one process per container
* Use **docker compose** to run several containers simultaneously
# Docker Compose
* create a **docker-compose.yml** file
* Configure the compose command:
version: '3'
services:
web:
build: .
ports:
- "8080:8080"
db:
image: "mysql"
environment:
MYSQL_ROOT_PASSWORD: password
volumes:
- db/data:/foo
volumes:
db-data:
* When you are done, use docker compose-down to close the container set
Bump
how did you do this ...? any extension to convert u tube video to text
Thank you for this comment
I was LITERALLY struggling with a Docker setup when this video came out. I know people are joking about how Jeff's reading our minds, but I'm scared.
That aren't jokes...
Its called market research, he is probably looking at search trends and making videos based on that.
I have no idea how you do it. You manage to teach an hour worth of stuff in 11 minutes. You deserve billions of views. I am literally learning everything from you. Super fast, and with almost no attention span. Thank you. Never stop making these things.
this 11-minute video got more content that my institute's 3 hr lecture
Dude modern Unis are shit for most programs, they're not as practical and they have to prioritize filling space over actually making sure the students know what they're supposed to. Especially for programming, they're getting replaced by online schools who give you exactly what you pay before. Instead of spending money on bloat and schools that look like castles
Schools generally teach way too slowly imo.
@@user-he8rl4sm3k nah universities don't need to teach programming. It's a prerequisite that can be learnt online. They teach higher level of information research on better algorithms, faster methods, new architectures and so on. It's like no university teach you basic math... similar story to programming
Haha the intro is so true , impostor syndrome for not knowing docker
This was absolutely amazing. I really struggle with long, drawn out videos and finding this video where it sums it up so beautifully is fantastic. Thank you!
He hit the right speed and depth. I just want to know something about all this, not slog through a two hour lecture with too much details, or be bamboozled by a short video where the explainer talks too fast and uses plenty of already-in-the-know jargon.
OMG, I just started looking for Docker videos right now and this showed up with "uploaded 10 minutes ago". You always know what I need! Thank you.
The amount of knowledge in every video is unbelievable. Props to you, you just made my tech journey a lot better
the best tutorial i have ever seen on docker...and the fact that it took barely 10 mins to complete the tutorial is exceptional !
i have to say i'm lucky i come across this fun, compressive, comprehensive, hands-on tutorial. Fireship man you are pretty amazing.
You summarized in 11 minutes what some guides take 2 hours to expose. To the point!
Weird. Iâve been spending the last few hours trying to wrap my head around Docker compose. Youâre a Godsend
I believe it's GodSent
Nexus999 Seriously?
@@Pogibakayo Sorry, you're right
Dude, this was so helpful I can't even explain it. Great explanation! This was perfect for someone like me who has linux system admin knowledge, but doesn't understand docker super well. Thank you! đ
I'm playing with Docker right now after seeing this video and it's awesome how powerful it is.
Spent 4 hours reading doc and playing around on my own pc with previous projects (web server, databases and so on). Microservices are great.đ
Excellent. Excellent. Excellent. Started playing with Docker in 2018, have seen numerous tuts and walkthroughs. Came back for yet another refresh and this short vid is the best by FAR.
Prolly the only channel I have turned on notification for.. đ„
This video was REALLY helpful!! This indeed resolved my insecurity for not knowing Docker.
I love that it is short, sweet, and beginner-friendly as usual đ
Wow, this is so clearly explained, even I understand it! I don't normally work in situations where docker is relevant, but some of the recent job prospects I've applied to mention Docker would be a nice extra skill, so I came to YT to find someone to explain the basics. I hit the jackpot here!
I want to thank you for all of these useful âquick startâ videos. Iâve always had a passing interest in coding, but I only ever went as far as messing with html and css in geocities and livejournal way back in the day.
I never thought I was capable of coding anything, but your videos make these complex, interconnected concepts seem more approachable. And as a person drowning as a Jr. SDET around my (very supportive) QA and dev coworkers, I truly appreciate these guides and tutorials.
Youâre a real one, Fireship. Thanks.
Right content from the right person. Never knew the flow would be so smooth to grasp. đđ±âđ
Definitely goes to my "references" bookmark!
You are incredible! I found the answer that had been digging in my head about docker. Thank you so much
Love your videos, basically you have the ability to compact things, without skipping IMO relevant information. Thanks a lot.
Uploaded 1mn ago, right in the midst of a Docker struggle, thanks Fireship (awesome content)
This 11 minute video is better than other one hour long videos out there. Thanks for this amazing content.
You are actually the best content creator for everything web related and more. I deeply thank you for teaching me almost everything I needed. You were the foundation of my progression
This was a very good primer for someone who hasn't been using Docker, I liked that special attention was called to the most important parts (the docker file!) as well as showing that just running a docker image won't expose its ports, I am sure I would have spent an hour trying to figure out why my docker image isn't working. I also liked the tip that stopping a container makes it lose its state, I was under the impression it was like a vm so I thought its state was saved, I probably would have made a docker image that included writing some local file, run it for weeks and then lost all my data! I don't think I've ever had as many conceptual misunderstandings cleared up in a row as this 11 minute beginner's guide. While I was just trying to fill in some small knowledge gaps, the gaps turned out to be much bigger than I thought and I would have been lost for sure. I appreciate the structure and content of this video, and how it explained the most important parts. It makes me want to watch all your other short videos of the same style, to fill in knowledge gaps I was missing. So far I only have a little time for watching videos while at work, and many other learning resources are blocked by my employer, so this is very good use of my time now. Thanks for creating this video!
At 4:00 You're looking at a Dockerfile with FROM as layer1 and WORKDIR as layer2. Now: FROM _does_ create a layer, but WORKDIR _does not_ -- the WORKDIR directive and several other directives, such as ENV, create metadata, not layers. All of the layer and metadata info is wrapped up in a JSON object that describes the image. But Dockerfile commands are not one-to-one with layers.
Amazingly concise. You deserve an award for the amount of information conveyed in 11 minutes.
You are amazing! You enable us to learn a huge amount of things extremely fast.
I would defintely love to see more Machine Learning content on your channel
i'll need to try it out, but you managed to make the concept much clearer in just 10minutes compared to the countless 2h docker beginner tutorials. great video
Awesome video, it served as a refresher for all the core concepts of Docker, you've covered almost everything in very little time. Great art of explanation. I must add this into my bookmarks. Will be waiting for more videos of this kind. Thank you man.
So unbelievably useful. I'm studying Computer Science and we got to Docker.
While our Professor is explaining the stuff around like what is IAAS, PAAS and SAAS,
we have to set up and work with virtual Machines and Docker to do the things behind the scenes.
Now im actually understanding why i do these things.
i bet this channel will grow to something massive in the developer community.
Its already massive , welcome :)
I'm impressed how efficient this video is. Thanks dude!
Thanks, this is an excellent video to watch after youâve done the official Docker tutorial. It ties up the fundamental concepts better than any other video or doc Iâve seen so far.
You managed to summarise so much in 11 minsđđœđđœ
Perfect timing, I was having issues with my assignment, and decided to browse CZcams whilst my image was getting build. Glad I got a mini-refresher and learnt some stuff I needed for upcoming tasks.
Thanks!
wow what level / CS you're in that require dockers? is it masters?
Probably just some elitist highschool in the US...
@@Dennis-Ong just a bach degree
@@Xajoc8 nice assumption that i'm in high school or in the us lol. i'm nowhere near either
@@Dennis-Ong jjjjjjÄ·Ä·Ä«
I opened youtube to search for docker tutorials then saw this in my sub box. That was extremely good timing.
This is the best explanation of Docker I've seen to date. Thank you!
I was interested in docker a hour or two ago, and you uploaded this video, thanks
... this was everything I needed, quick, straight to the point, very dumbed down. Loved it. Subscribed. Thank you.
I love your videos... you seem mostly Tutorial Videos are very "slow"...
It's like they are trying to explain stuff to an intern... but most of the programmers anyway think *fast*... I mean nobody reads docs like one reads a novel... we literally scroll through the docs and then in the end get the abstract of it...
Your videos are quick & engaging, containing all the important information...
Thanks for that :)
This was very easy to follow and went over so much so quickly. I did not expect to understand so much after having watched this a single time.
Now all Devs be "ps"sing at work đ
Omg, lol!
Docker is in my resume now, thanks
If I had watched this video last week, it would have helped me so much. I think you might be my favourite CZcamsr from now on, you give so much information in such a short video length.
This video is gold. Most of Fireship videos are great, but this one has to be one of my favorites. I hope there's a continuation with kubernetes or something similar
Two minutes in, and i already understood more them in all other videos combined !
Such a clear and well paced explanation. Well done man.
Best explanation I came across. I took a few trainings in Udemy and plural sight but this short video has better and a more clear simple approach to this technology
You're videos are so great and beautiful that even when I already know most about the video topic or I don't want to know about it I still watch the video. Great work! Keep going!
Concise and to the point. Just what a beginner like me was looking for! Thank you for this awesome video!
Thanks, man. I've been feeling so out of the loop while everyone and their mother drinks the Docker/Kubernetes Coolaid... and I've always been low with my self-esteem, but now that I actually have to learn this too I feel overwhelmed.
You are the master of Docker. You explain short but very clear! thanks
in 11 minutes your explained docker totally... that was nice!
Couldn't agree more with first 5 seconds! Love you, Jeff! You cured me from my impostor syndrome xD
love the approach, line by line, file by file just for međ€Ł
You made me fall in love with programming once again
Now THIS was a great tutorial. Very concise and to the point.
That opening line is incredible! đ€Ł
I canât forget docker ps cause of the way you said it
Wow that was WAY clearer than every explanation I got from DevOps nerds at any of my past jobs
Awesome channel, I've been here for more than a year learning Angular, Rxjs and... đ„đ„.
Always awesome videos.
Thank youuu
Notification Squad
gg
AAAOOOOOOOOOO!!!!!!
developer : what make his channel special?
me : he know how to say docker ps
Unreal timing! Just started my first software testing job. Need to learn docker. I am SET
I like your practical stand point. So simple and easy to understand. Well explained.
8:09 when you stop a docker container, the data in the container is NOT LOST. You can always start the same container (not run) that has been stopped. The data is lost if you remove / destroy the container.
False
@@challengeyourmind3937 how is it then if this comment is false
If someone wondering, You can also write the compose file in JSON for better readability.
nothing like useless quotation marks, commas and brackets that'll scream at you if your forget them
@@jvcmarc Just because you "don't know" how to use something doesn't mean it's 'useless', am I right?; đ
@@XiaZ oh, I know how to use json, I'm just saying the syntax is unnecessarily complex and could be simplified
having to put quotation marks around fields is really weird and it looks awful
the fact that it requires a comma after every field, but refuses to compile if there is a comma after the last field is really annoying, and makes updating json frequently a bummer (even in javascript you can let the commas on the last properties)
and brackets is really more of personal taste, brackets vs indentation and all that
and dude, did you really get defensive over a general purpose dev technology from the 00,s? maybe chill?
@@jvcmarc To each their own I guess, it's just that I haven't got any syntax error complain in like, 5? Maybe 10 years?
It's just how my brain work, if you forgot any small mistake, I'll complain before the complier got a chance to do. It's my work to ensure high quality code, and I enjoy the suffering of other.
@@XiaZ lmao, yeah, I'm somewhat new in dev, I've only been programming for 3, maybe almost 4 years
but I'll always choose the most developer-friendly option, if I can choose not to bother with brackets, commas and quotations by switching to yaml, that's something that I would definitely consider
json still has it's place, obviously, I would never return yaml from an API, just use it for config files locally
Dude the way you explain things is unbelievably straightforward, if you would create a course about it, I'm in!
What a video! Full overview in 10 minutes, thanks đ
Would appreciate anyone telling me the name of the intro track
2:11 had me in stiches đ
Thank you! After watching this video, I got promoted to a senior software engineer from a junior SWE with 5 months of experience!
Short and to the point. Thank you for sharing this. Subscribed.
A tip if you get a bit carried away and start running everything in docker, like you IDE; If you try to start a docker container within a docker container you will have some problems. "dind", docker-in.docker, came to solve this and it solves a lot of things. But if you have your IDE in docker, and want to run a docker container for say a test (like spin up a mysql-db-container so you can test your db-logic), dind is not really what you are after. What you are after in cases like these is for your container to be able to start containers on your host-docker. You do this by mounting you docker-socket as a volume to the container. Here is a nice write up about it all: jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
I jumped when he say "ps" and thinking someone is calling me
I usually call my cat PS...
Super simple and easy for beginners. Great work
Thank you so much for this video. Trying to get ahead of the game as a computer science junior in college.
Last time I shuffle sharted at a party I was asked to leave...
Last time I shuffle sharted I ruined my socks.
Oh my god I was just looking for a beginner docker tutorial from you yesterday and here it is
Thanks for your outstanding content! Just created and ran my first Docker image! What a rushđ€đ„đ„
Great tutorial! Short, simple, to the point! Thx!
I never like or comment any post in social media but You're Just Awesome Buddy, Keep up the Work :)
DUDE!!!!!!! thank you for simplifying this a bunch U da real mvp
Loved that intro that's exactly the way it goes
Bless you for this straightforward explanation.
so informative and concise, thank you fireship!!!
Your channel is one of the best channels on youtube ever, and your videos are treasures
Best info/tutorial on docker i have ever seen. Very Thanks man
that's why I love the internet, thank you for the brief and informative tutorialđ
amazing tutorial, explains the basics in an understandable way
I was needing this. Thank you!
Love your videos.. no fluff, really concise, clear as a bell! Thank you!
Love this format. Glad I didn't need to sit through a 2 hour video to get the gist of things