Modern Python Projects Transcripts
Chapter: Deployment
Lecture: Docker Compose

Login or purchase this course to watch this video and the rest of the course contents.
0:00 We only really scratch the surface of what the Docker can do. Our usage was very basic because all we had to do was to start a
0:10 gunicorn server and that was it. We didn't have to connect to any database. We didn't have to store files in Amazon s3 bucket or set up redis for
0:21 caching. However, once your application starts growing, you will need to add more things.
0:28 And this is where you will need to use something like Docker Compose.
0:32 Docker Compose lets you configure different services like a Web server or a database and
0:38 make them work together. So you would have one Docker file for, Let's say, gunicorn, another Docker file for Postgres or mySQL database
0:47 And then you would use docker compose file to connect them together, open some ports and let them talk to each other.
0:55 Covering Docker Compose is a material for a whole new course, So I'm not going to get into that, especially since this chapter is already long.
1:05 But if you go to the Docker documentation, you will see that there is a section dedicated to Docker Composedand one of the
1:11 things there is an example of how to use Docker compose with Django. So, if you go here, you can see that we have a Docker file.
1:22 And then we have the Docker compose file, where we specify that we have two different services. One is a database that is using the postgres image.
1:32 It's defining some environment variable for the user name and password. And then we have the Web service,
1:37 which basically starts a Web server mounts on volumes, open some ports, and it depends on the database.
1:46 So, obviously, Docker documentation is the best place to get started.
1:50 But usually what people are looking for are some good examples of existing docker compose configurations. And for that you can goto awesome-compose,
1:59 GitHub repository. This is a repository that contains examples of different Docker compose configurations
2:04 The good news is that it contains a lot of different configurations, and each of them has a nice read me explaining how to use it.
2:18 The bad news is that for Python, you only have the NGINX,Flask and mongo DB or my SQL combination.
2:26 So I suggest you take a look at how the existing Docker compose file might look
2:31 like, and then you can make the necessary changes and that concludes our deployment chapter.

Talk Python's Mastodon Michael Kennedy's Mastodon