‫All right. Enough of the lectures.
‫Let's actually give you a little bit of an assignment. Now that you've had some chances to play around
‫the container commands
‫in Docker, I'd like to give you a little bit of homework to start up multiple containers. We're going
‫to go through some of the process of what it's like to set up multiple types of images in different
‫containers at the same time.
‫You're going to maybe need some documentation with this.
‫You know about the --help command.
‫With that in mind, there's also docs.docker.com.
‫If you haven't been there, definitely take a few minutes to check it out and just click around.
‫Even if it's not something you need to look at right away, just get an idea for the breadth of documentation
‫there.
‫The actual website is totally open source and you can actually use GitHub to add documentation or
‫recommend changes. It's rare that a day that goes by that I don't go to that website. There is constant
‫amount of new information there.
‫I highly recommend you check it out.
‫Most of the time when I'm actually searching Google, it ends up being one of the two or three top choices
‫anyway.
‫You're going to start up a three-container application. We're not actually going to set up these
‫three different containers with application data or our source files.
‫I just want you to get the ideas around how to start these and how they're different and managing
‫them together.
‫You definitely want to use the -d for detached.
‫Then I recommend you always use --name. That's just easier to deal with when you're working
‫on your local machine.
‫You can name them whatever you'd like. I need you to give each one of them their own port because
‫each container can't run in the same port as other containers
‫if you're exposing them at the host.
‫Right.
‫If we're going to allow the host to listen for each container and forward traffic, they all need to
‫run on different ports.
‫The nginx is going to act as our proxy in this case, and it's just going to sit on port 80. The
‫apache server or httpd is going to run on 8080.
‫Then the mysql server is running on its default port of 3306.
‫Again, these actually aren't going to be three containers that talk to each other in any way right
‫yet.
‫But we're just going to start them up and then tear them all down again.
‫Something that you haven't yet experienced is one of the options for the container run command is
‫an environment variable passing.
‫So, -e or --environment will pass any environment variable you want to pass into that container.
‫This is a very common way for us to pass environment based settings into our containers.
‫It's quite often to have different environment variables for test or dev, versus production and the
‫environment option is how we do that.
‫With the mysql image you'll be using,
‫it actually has an option for setting a random root password on bootup.
‫The way that you find that password is actually going to be using the logs command to see at startup
‫the first time and it will spit out to the logs what that random password is going to be.
‫Once you start up all the containers, and you think it's correct, you can tear it all down again
‫with the stop and the rm commands.
‫I'd like you to use the ls command to make sure that you have them all started and that they're
‫all cleaned up.
‫You might need to use the ls -a to actually make sure that you've removed all of them. I'm
‫going to leave a video after this that actually shows how I would do it in case you get stuck.
‫Good luck. We'll see you on the next section.