Hi I'm Mike Rogers, I'm a Ruby Developer from the UK! I really like Docker! It makes me very happy, as Docker solved a lot of my developer woes & I want to share it with everyone!
I'm going to give you an introduction to what Docker is. The aim of this talk is to give you enough confidence to know what on earth it is, and hopefully give it a try.
Seriously! Why am I telling you about this? I like to make sure you know why I think this solves problems. I'm going to go through some development scenarios where I think Docker would have helped.
This is a true story! I worked on a product where every developer install the database tool we used (Postgres) at different times & as a result we all were running different versions. One day we had a developer use a new SQL function which solved our problems really well. We got to production & it didn't work. Had we been using Docker, we could have say "Everyone use the same Postgres version as Production". Plus it would have kicked us into get around updating our postgres version.
Another true story! Have you ever picked up a legacy project which had a bunch of steps to get started? Installing some of those packages is hard! Sometimes they throw cryptic errors due to MacOS (Or the OS) changing something. Even worse, what if you end up with a random dependency from that project which screws with another project. It's all really messy. I totally hide in the toilet as a junior dev when I couldn't get an app setup on my machine & I didn't want to ask for help. With Docker, we can setup our apps with very few commands and depending on how it's setup you might not even need to look at terminal.
This is my big fear! Someone has a project & I don't know how to turn it on. With docker, we can make it so how we setup & run our projects pretty much the same. With Docker you're creating a "little box", with everything your app needs to run in that box. Once you're done, you can throw the box away.
Seriously what is it? This is kind of simplistic definition, but works.
Here are some other definitions I'll be using! We build images, we run them in a container. Image: It's like a snapshot of a computers disc drive at a point in time, which we start our app at. Kind of like if you have Git version control looking at an entire Disc. Container: Runs the image Alpine Linux: Most images start with Alpine as their base image Don't worry if this terminology seems weird.
What are the steps to get going & how do you get the benefits!
First off, you need to download it
This will give you the desktop app
After this point you'll have access to docker & all of it's commands in terminal.
So if you wanted to run Ruby without installing you, could run this command, It'll download image to run ruby, then you'll get a little ruby console to run commands. Plus after I'm done with it, it'll go back to it's original state. So I can make a total mess & it'll be fine. All running in a little sub computer! This I think is pretty powerful!
What if we want to create an image, which has a few packages installing with out app there. We can go to our project root, add a Dockerfile. You can kind of reason what it might do here! Like, we're going to install yarn & copy the files, bundle then make it so it turns on
Then you can totally build that image & run it! Which is super cool! You can push that image up & share it with people, it's almost job done! So you could make a little CLI application in any language you want, and share it with your mate & they can run it. They just have to download that image
After i built a few docker files, i wanted to find a way to manage more of my app! docker-compose was the answer. it's installed along with the other `docker` command, it should be there.
With Docker-compose, you setup a YAML file called docker-compose.yml which kind of just says: "here are the things my app needs to run & some configuration". In this case, I've asked for a specific version of Postgres.
Here is my setup if I was to do WordPress. I don't need to setup PHP, or download any Wordpress files. I just need a wp-content folder.
From there, can run this docker-compose up command & it'll just turn on everything we need. It'll even build the image if it needs to. So potentially the only setup notes you need in a project is "run with docker-compose up"
I can also go in & run adhoc commands. This is really cool!
I can also just run on the services I care about. So sometimes I just turn on my database, then run my rails app via my local machine.
There is even a VSCode integration
There are some!
It's a bit of a resource hog on MacOS, it's better on Ubuntu. Machine within machine will be slower. You can delete the images, but they do add up.
I also like this quote from Nicky T! I was watching him on a stream debug a Docker issue & he dropped it. It's not a silver bullet, you can still get some quirks slipping through & some people use it in different ways.
Breath & tell them your name! I hope this inspired you to want to try Docker!