#100DaysOfWeb in Python Transcripts
Chapter: Days 97-100: Docker and Docker Compose
Lecture: Running a Docker container

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's try to run a container. Notice up here we have our docker app running, so we should be able to run docker and have some commands happen.
0:10 Great, so the first thing we can do is we can try to run an image, let's just try to run that docker image
0:16 so we'll say docker run ubuntu, could just say it like that or we could say latest, or we could even say :18.04 let's just go with this.
0:27 Now, before I run that, let's do a docker images and it's going to list all the images on my system. They're none, right, empty.
0:36 So, let's go back over here and try this again. What's going to have to happen is this is going to have to download, at least the Ubuntu image
0:44 maybe the Ubuntu image is based on other things and we might have to download like a whole series of dependent images here.
0:51 We're going to run it, turns out the outcome of it is going to be a little bit underwhelming but it's going to be the first step.
1:00 Didn't find it, so it's going to go and download it. Some kind of weird network glitch. Okay, so we downloaded a newer image for Ubuntu.
1:14 And then, I guess we ran it, like let's try to clear the screen, we'll say docker run, it's local so it just ran, so how long will that take.
1:23 It didn't take very long, started the whole thing up basically what that's saying is just starting up the system and then waiting for, well nothing
1:30 and then it exits. So, we can do a little bit better, we can do things like go in here and say I want to run it in interactive mode
1:38 and interact with it, and the thing I want to run is bash instead of just the main shell. So now here I can say ls, I can say ls hostname
1:47 all the things that happen in Ubuntu you can see the host name here, is this container name. And I could even ask for all the running processes.
1:56 How exciting, the only thing running on this process is bash and ps, which was running temporarily to figure out what was running, which was only bash.
2:06 So there's really nothing else running here it's a super super simple version of Linux. It didn't have a bunch of services and demons and suffering
2:16 it's just this. Whatever you ask to run here, well that's what's running. Later on, we're going to run Nginx, and we're going to run
2:23 our web server, and things like that. But for now, we're just running on bash. Finally if we say docker images, you can see over here
2:34 that we downloaded this, which created 25 hours ago so it's pretty new, but the timing is still off with those
2:41 vulnerabilities I showed you, so we're going to have to fix it but it's mostly a brand new one. Now, we could also ask docker ps to ask what images are
2:51 running, and if we say -a, it'll show you the ones that ran, so you ran it like a couple of times when we were messing with it.
3:00 And when they run, they each get a container id and you can work with them, and they also get a funky name like trust in nightingale, or vigilant noble
3:08 things like that so you can refer to them either by their name, or by their container when you work with them with the commands.
3:15 So that's how we run a docker container.


Talk Python's Mastodon Michael Kennedy's Mastodon