What Is Docker Used For?
Docker is used to develop, test and ship apps the same way everywhere. It fits any app that must run the same on a laptop, a test server and a live server.
Run a database without installing it
One command starts a database in a container. Nothing is installed on the host.
docker run -d --name db postgres:16-alpineRun a web server the same way
The same pattern starts a web server in a container.
docker run -d --name web -p 8080:80 nginx:1.27-alpineExample
docker run hello-worldKey points
- Use Docker for local development, so every developer runs the same setup.
- Use Docker for testing, so tests run against the same app every time.
- Use Docker for shipping, so the live server runs the exact tested image.
- Use Docker to run databases and tools without installing them on the host.
- Docker does not fit everything. A graphical desktop app is a poor fit.
In this example, Docker runs the same test image that runs on any machine with Docker. The same image on a laptop, a test server and a live server prints the same greeting. That sameness is what Docker is used for.
Note
Docker runs the same app everywhere, but it cannot fix an app that is broken.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
What is the main use of Docker?