 All right. Hey everybody. We are lives. Thank you so much for sticking around We just had minor technical difficulties, which is the theme of the day with Skype So, oh Mike, can you see you are you there? I yes, I'm here. Your video looks frozen, but that's okay You look like you're mad I'm so mad Oh, well So what are you speaking to us today about Mike? So today we're gonna talk about using sequel and containers to do some development work and just some Random tasks that you have to do without having to install it on your development machine. Awesome. Let's get started Okay Go and show your screen whenever you're ready. Oh Let's see. I'll see it's not sure it should be showing. Oh, okay. We'll switch over there. We'll do that Hopefully so. Hey, there it is. I see it now There it is I've got as much hair as the dotnet bot perfect But my beard's not nearly as pretty as Mark Millers. What's that amazing or what that is so good at that. Yes. Yes So, yeah, we're gonna talk about Some fun stuff or or somewhat I think it's fun my threshold for fun is pretty low I'm Michael Jolly and I'm happy to talk about using container I sequel server as part of our development life cycle So one of the greatest things about doing this Is uh This is all our twitch family. I see so many twitch friends in chat. It's just this is fam, right? This is family time So let's talk about it. Let me tell you a little bit about my background I've been a software developer and architect for nearly 20 years primarily focused on mobile and web Uh I'm a live coding on twitch three days a week as part of the live coders team with c sharp fritz jeff fritz And I'm an office hero ambassador. I love talking about security. So Feel free to hit me up on that because you know, that's fun stuff And when I'm not running code, I'm probably spending time with my family playing music Or trying to exit them It's a losing battle so One of the best parts of my job Is to find new technologies and tools and processes that help people in their developer experience And I'm excited to share one of those with you today. I've been using it for probably four or five months and it is Legit it is too legit. In fact to quit. Yeah, I said that So docker, we don't need no stinking dockers What is docker? Let's just go really quick High-level overview. You will not know all the intricacies of docker after this, but what is it? The easiest and some would say too simplistic way to describe docker Is to compare them to virtual machines. They are not virtual machines But both provide similar resource isolation and allocation benefits, but they're fundamentally different because at its core dock vm virtualizes hardware whereas Containers virtualize the os and really that's kind of a heavy-handed way to describe it Containers would probably be better described as a system service They're isolated and don't really know about anything you don't specifically tell them about For instance, they don't need to know about networking. They don't need to know about peripherals Was that a word? Well, it is now and so on. You know, it doesn't have to know anything about that It's just a service that's running If you need it to have network access you tell it about network access if it needs to know file access you tell it about file access but another another reason we want to use docker is because Man the containers the images are so much smaller compared to like a vm Uh image or or or just even a whole install a sequel server The images can be in the tens to a hundred of megabytes versus gigs Of uh, just the install for sequel, right? Nobody put sequel in a container. What are the benefits to putting it in the container? Why would I want to do that? well I'll tell you why I'm glad you asked first is the reduced footprint on your local machine So if you've ever installed sequel You know that it's a big install and then I've got to deal with updates periodically And I don't want to I don't want to I don't want to fight that battle, right? I mean, I only need sequel server when I'm developing or maybe having to do some kind of data manipulation for a client Something like that, you know, I don't I don't necessarily need all that stuff all the time second One of the benefits is we get cross platform support So all of our friends on linux and our friends on max who are developing can all kind of share In the joy that is developing against sequel without having to you know, install that there, right? uh, and the third one is um One less although massive attack vector on our machine If you've ever installed sequel server and watched your error logs You know firsthand that sequel server is one of the most attacked pieces of software in the world It's insane and I don't want to be exposed to that. I don't even want to think about that, right? So by running sequel server in a container You get all the benefits of a full install while being able to throw it away when you're done working with no impact to your local development machine That's right. Hashtag not on my machine so Let's let's well before we get into the demos. I do want to say you Probably shouldn't be running sequel server in a container in a production environment While only a sift deals in absolutes I will say it would be a very unique use case that you would need to run sequel in a container in a production environment Uh, but we can use it for day-to-day tasks and to improve our development workflow So let's see it in action. Are you ready? First i'm just going to show you some some code. We're going to run in the terminal Uh spinning it up in a container. Basically, we're going to run a command We have to have docker installed, right? That makes sense And we're going to run that command up there. That's kind of in the teal And basically to break down what each of those points are you're setting two environment variables. One is the sa accounts password shout out dot netcom We're also going to accept the eula Just got to do it Name is optional, but recommended because it names that container that's running And then otherwise you're going to have to reference that container by like the id which is god awful Don't do it. You'll love me if you if you'll you'll love me the minute you do it and remember a mic said don't do that And then finally the dash d we're telling uh, we're telling docker what image we want to use to build that container So in this case, we're using uh ms.sql server 2017 and it's actually running in, uh Linux so that's pretty cool Uh, wait, let's do that. Matter of fact, let's go back and let me escape out of that. And why don't we Do some magic In power shell So let me go. We're going to run that command Trust me. We're going to run it. It's going to be so cool Okay, so there's that command. I'm just copying and pasting it in Hit go go gadget run and there it is So so it gives me this gobbledygook and that's that image. You never want to see that that that string so, uh With that running we should see some docker containers running. So if I well, let me not use my aliases. Let me long form it here Uh, there's our docker container. Look at it. It's beautiful Look at that sucker running for 18 seconds named sequel 01 Well, so let's go through a use case, right? So I can tell you we have a client who uh Oftentimes sends us a backup of their one of their production databases and says, hey, we've made some changes We want you to refresh the uh sequel database that you have and you're developing against to have our newest stuff So what it'll do is what will we keep their database in azure? So they send us a backup. Well, normally you can just import a backup file to azure But you can't have custom security logins with that and wouldn't you know what this client has? Custom security logins because you know customer is gonna customer So let's go into That directory. I've got a folder here and I've actually got a backup, right? Uh And I'm going to Let's see. We've got that container out there. Let's just do this. Let's talk about Maybe Can we do it? So we've got our container running. That's what we that we we executed this to do it Now let's talk about copying files in and out So basically this customer sent me a backup file and I need to get that security login out so I can upload it to azure So we're going to run that command there with docker copy And we're going to copy in the first parameter is the source file. The second parameter is the destination file And if you're going to use that you're going to use a container as one of the source or the destination You need to prefix it like container name Or id colon the path. So sequel one is the name of that container I spun up So let's run that same command And I'm going to in this sources data folder. I'm going to copy in that Back up client going to client dot back And I'll come over here in my command line copy up that to that container And it just comes up now one of the cool things I did in this Um when we executed the command to start it up I exposed the port that's up here port 1433. I told it. Hey in that container you have 1413 1433 Map that to my local hosts my host machines 1433 so I can come into sequel And connect to that sequel server Using the password Looking here. There's no databases. We just spun it up, right? There's no databases here But I can come in and say hey restore a database because I copied that back into the container I can now magically select it there and that that you'll notice the path var Ms. Equal data that it no window path Hit okay Well, thank you Open it up Let's see now. I know they've got yep. Sean Hasselhoff. I knew they had a custom login in there So I'm just going to remove him. I don't need it. I'm just want to get this Okay, so now I need to do a backup Uh backup Yeah, yeah default stuff. Yeah, just do it make it so number one Okay disconnect from that. So now in that container I've got a copy of a backup file in there that has that security login removed. So I'm just going to Let me see. Let me copy that command in it's basically the same copy command But the parameters are back are swapped. So I'm going to copy from the container out to my local machine And here I've got to back up a matter of fact if I go in to delete that to show that it did it Because you know don't want to be cheating here. There you go. There's that backup from the container that doesn't have that Security login. So now I can go in there and have fun with it So it's cool stuff. You can map drives matter of fact we can um Let's see. Let me come in to This slides again. Let's slide on up in here. Yeah. Yeah. Yeah, that's a little late Port forwarding and volume mapping. So we just showed you port forwarding because we added that p 14 33 33 And that's mapping it from the host to the inside. We can also map a volume. It's basically mapping a drive, right? So in this case, I would be saying D sources data, which is a directory on my machine Map that into far up ms-sql data. That would be a great way to persist that data because once the containers are gone Let me get rid of that thing sql one D remove sql one Goodbye to you. So now we don't have any containers And I'm going to run the same command again to create a container But this time I'm going to tell it. Hey map that D sources data, which is the folder. We're in over here to that directory inside the container, which is where Microsoft sql server Stores its data In this container. So just hit that it's going to execute there. I got a container. You should be running Now and then look over here in this folder all of a sudden my master database starts showing up my model My temp db all those files start showing up. So now I can log back into that again Like a boss. I can come in here and create a new database Yo, this is cool Hit okay And I've got the database in ssms just like normal, but I've also got the mdf and everything over here So now when I disconnect from that Just get out of it I'm going to come over here and say, you know, stop that container. As a matter of fact Heck, I hate it so bad. Just delete that container. It's no longer on my machine I don't have sql installed on my machine now But because I mapped that drive, I've still got the database and the data that can use other places Yeah, it's the best table name ever and yeah, I'm in chat all up in your chat reading your messages Yeah, so so that's pretty cool. So We can do everyday tasks like that, but let's take it a step further. Are you ready? Ladies and gentlemen, are you ready? Let's go into visual studio because you know developer gone develop So in here, I've got a very simple app It is so simple in fact that it will amaze you All I've got is a couple classes, you know client class. What's it going to do? It's got name created. We're going to use some entity framework core Right because that's how that's how we play here Uh, and then I've got some things, you know Normally my connection stream is going to be some environment variable super secret connection string But uh, if I'm in debug, I'm going to tell it. Hey, the server is called sql demo The database is called omg data And there's my username password. Now, of course, that's just in debug, right? So there's just some stuff. We're gonna we have a method to seed the data if we need it We got our model. This is all just ef core stuff. We're not going to get into that, but trust me. It's amazing Uh, and then we have one database migration that basically builds out the database with the clients and the uh And the uh address table and then I've got this like Web app this dot net core Mvc or asp net core mvc app and all it's doing is spinning up and in that home controller I get that uh context from that thing Pull in the clients and return it to the index view and the index view just basically does a Tr builds a table with the id and the name now my seed data method. Um Is running every time In my startup, I've got it telling it. Hey omg context migrate that data please so that we have it So then When I run it nothing's going to happen. It's going to bomb because it's going to say that database doesn't exist Except I have a docker file here because of course. I'm going to eventually deploy this asp net core app in a docker container So I've got a docker compose and that docker compose. I say spin up that doc that sequel docker web app Uh and call it sequel docker web, you know, and then it depends on the sequel demo service Which is basically the sequel 2017 We're going to call it sequel demo and because it's in that docker container It's going to put those on the same network just amongst themselves I've exposed the port here so that I can access it with ssms if I wanted to and then I've also mapped that drive so that Uh We can see the data later on so that container was gone so I can delete those files and I'm going to debug this web app and If all the demo gods have been sufficient sufficiently appeased today We should see a browser open up And magically it'll be just the default asp net website except it should list One client so that seed database method basically seeds one client and one address And right now it's starting up. It's compiling it all it's going to spin up an asp net core Container and it's going to spin up a sequel server And there it is. Look at that. I've got one record with just the id that's a grid that the customer's name And when I get done I can close this thing down and Stop debugging get out of it all. I can go delete containers now. Look at that. It created my omg data database So I still got that that I can play with if I need to I can access it I could spin up that container and connect to it through ssms if I wanted to matter of fact Heck let's do it. Why not do it live? Let that thing start back up. We'll connect to that sucker like a boss Let's see. We want to connect and we're gonna have to wait for it to finish the loading Okay, I got my web app up so proof in the pudding the web app is running. So the sequel server should be running omg data omg data There's my clients my addresses It's got the migration history because you know That's how we roll with ef core Isn't that awesome? I've got my data there. I can sample it in ssms. So if I'm debugging I think there's something wrong with the data. I can still play with it uh And then I can close it down. So this is like legit just a database for me and my development environment And when I'm done with it, I can say get out of here sequel and you're not on my machine Because I named it. I can just say docker Why don't you remove? sequel demo and sequel docker web because I'm done. Oh, I had to stop them d cx sequel demo. I apologize for the dcx. That's an alias which You can get from the dev toolbox power shell Extension uh, it's pretty cool And it also works better if you type the names right just to you know Little little helper there for you if you type the name of the container, right? It always removes it better So now I'm done with visual studio. I'm done developing but because I mapped that drive I've still got my data there if I want to use it Or if I didn't map it, it could just go away too, which is wonderful It makes everybody happy if you're not happy with that Well, I don't know what to tell you call mark miller because that presentation was amazing So with that thanks everybody for listening to me talk about this It's it's always fun to hang out with all of you my friends on twitch and The interwebs This is the michael jolly. That's right bobby johnson You can find my slides the the code that I use some additional links to help you start doing this at that bitly link there You can find me on twitter at michael jolly Uh, I know it sounds weird, but you can also find me on the web at michael jolly.com. I know it's hard to remember Uh, and then of course i'm streaming three days a week on twitch. I'd love to see you there Uh and hang out with you And uh, and that's it Anybody got some questions? Yeah, so I've got answers. We've got some can you hear me? Okay? I can't hear you sweet So there we go, uh, so yeah, we have a couple of questions that people have been posting people may mostly having, um Issues with oh there you go. Perfect. Thank you for turning the camera on and off. That was perfect That's how we do it in developer land. That's right on and off so, um With regards to a hey ea from whatever else, but the one that's here that I think it's going to drive some good conversation is um molten, um MC backers asking Why wouldn't you use docker and sequel server in a production environment? Why is that an issue? because Okay, so so see think of docker as like a a service right a system service that's running If you have like a little process web app something very specific like that perfect for that scenario You wouldn't want to try you know Think about like microservices really right, but you wouldn't go put sap in a container. It's just too much I mean You're gonna You're gonna you're gonna shoot yourself to be honest. You're you're not gonna last a year You're gonna drive yourself crazy same way with sequel server. It's a little too big And then you get into issues of scaling that right For instance, like I showed you how to Mount a drive to like the host machine for the data. So that data persists Well, that would be the only way you could do it because a container is transient It goes away and comes back and come goes away and comes back Well, if you don't mount that to a drive the data is going to go away with the container That is bad news if you're running in production Right But if you did mount it and you tried to scale that sequel instance You're going to have issues because you can't mount all those containers pointing to that same data file And and live Things are going to go squarely real quick when all those containers are trying to access the same mdf yep But it's perfect in these little small scenarios where you have just some tasks to run Where I don't have to deal with like the full big install. I don't have to deal with Managing updates and all that kind of stuff and firewall settings to make sure I'm not being attacked Matter of fact, if you don't forward the ports to your host machine like I showed you There's no exposure at all. It's only available in that little docker network, which is really cool. Perfect Yeah, I was just I was looking at the chat here and Molten backers says like good cool. Good to know. Thank you for answering my question But that was really great. Uh, good. Good you everybody. Don't do it. Everybody loved the presentation You had an awesome job. I knew you I knew you would based on our tech check A couple days ago. So thank you again, uh, michael for taking the time to Chat with us and to share your knowledge and your passion Absolutely your humor Here with us. What were you funny? No, I'm kidding So we are gonna uh for everybody watching the stream We're gonna get michael off the of the skype here and get um, suiki Who is our next presenter? We're gonna talking about mixed reality and xamarin Oh, that's nice. So we are gonna be doing that here. So we're going straight into the slate and going Mute for a little bit. We'll talk to you guys in a little bit adios