DOCKER - 10 Practical Exercise v2

Hello everyone and welcome to this introductory course to Docker. Today we are going to do a little exercise. Now that you've had a chance to familiarize yourself with container commands in Docker, you can try starting multiple containers. We will see the process of setting up multiple image types in different containers at the same time. You may need documentation for this. There is of course the --help command but you can also go to docs.docker.com. If you haven't been there yet, take a few minutes to go check it out. While this may not be something you need to look into right away, just give yourself an idea of the extent of the documentation. The site is completely open source and you can use GitHub to add information or recommend changes. There is constantly new information on this one.
You will start a three-container application. We are not going to configure these different containers with application data or source files. We just want to find ideas on how to start them, how they differ and how to manage them together. You will definitely want to use the -d for detach. Then I recommend you always use --name. It will be easier to manage everything when you work locally on your computer. You can name them whatever you want. The only need is that you give each of them its own port because each container cannot run in the same port as other containers.
If we allow the host to listen to each container and forward traffic, they must all be running on different ports. The nginx will act as our proxy in our case, and will stay on port 80. The Apache server or httpd will run on 8080. Then the mysql server runs on its default port, 3306. Again, it's not actually three containers talking to each other in some way. We'll just start them and then delete them again. Something you haven't experienced yet is one of the options for the container's run command is to pass an environment variable. So -e or --environment will pass any environment variable you want to pass to that container. This is a very common way for us to pass environment-based parameters into our containers. We often resort to different environment variables for testing or development as opposed to the production and environment option. With the mysql image you will be using, it has an option to set a random root password on startup. To find this password you will actually have to check the logs to see on startup the first time it will show in the logs what this random password will be. Once you've started all the containers and you think it's okay, you can kill everything again with the stop and rm commands. You'll use the ls command to make sure you've started them all and they've all been deleted afterwards. You may need to use ls -a to make sure you've removed them all. I now let you do all this on your side and you can see the solution in the following video. So that's all for this video, but see you soon for the next one.