Your First Container
Start with hello-world
Docker downloads the image if needed, starts a container, prints a message, then exits.
docker run hello-world
Run nginx in the background
The -d flag detaches (runs in the background). --name gives a memorable name. Map host port 8080 to container port 80.
docker run -d --name my-nginx -p 8080:80 nginx
Visit the site
Open http://localhost:8080 in a browser. You should see the default nginx welcome page served from the container.
Use helpful flags
--rmremove the container when it exits-itinteractive terminal (for shells)-ddetach into the background-p host:containerpublish a port
Comments
One comment per signed-in account. Comments are saved with this page’s URL.