2 Understanding Docker and running Hello World
It’s time to get hands-on with Docker. In this chapter you’ll get lots of experience with the core feature of Docker: running applications in containers. There’s some background here which will help you understand exactly what a container is, and why containers are such a lightweight way to run apps. Mostly you’ll be following try-it-now exercises, running simple commands to get a feel for this new way to work with applications.
2.1 Running Hello World in a container
Let’s get started with Docker the same way we would with any new computing concept: running Hello World. You have Docker up and running from Chapter 1, so open your favorite terminal - that could be Terminal on the Mac or a Bash shell on Linux, and I recommend PowerShell in Windows.
You’re going to send a command to Docker, telling it to run a container which prints out some simple "Hello, World" text.
Try it now
Enter this command, which will run Hello World container:
docker container run diamol/ch02-hello-diamol
When we’re done with this chapter, you’ll understand exactly what’s happening here. For now just take a look at the output. It will be something like this (see figure 2.1):