Run Your First Container
Now that you have Docker installed, let’s run something! The “Hello World” of Docker is a simple image that prints a message to your terminal. 🐳
The Magic Command
Open your terminal and run this command:
docker run hello-worldWhat just happened?
When you ran that command, Docker did four things:
- Check: It looked on your computer for an image called
hello-world. - Download: Since it was your first time, it didn’t find it. So, it automatically went to the internet (Docker Hub) and downloaded it.
- Create: It created a new container from that image.
- Run: It ran the container, which printed a “Hello from Docker!” message to your screen.
How to see running containers?
To see a list of containers that are currently running on your machine, use:
docker psTo see ALL containers (even the ones that have finished running), use:
docker ps -aKey Takeaway
You don’t need to manually download things. Just use docker run, and Docker handles the rest for you! ⚡