1. Inspect images
docker images
docker image inspect nginx:latest2. Run a container
docker run -d --name web -p 8080:80 nginx:latest
docker ps
docker logs webPort mapping 8080:80 maps host port 8080 to container port 80.
3. Add a new website version
Create an index.html file and a Dockerfile based on your existing image:
FROM devopsdurga/myprojects:v1.0
COPY index.html /usr/local/apache2/htdocs/index.htmlThis document root is for the standard Apache HTTPD image. Verify the base image and web server before using it.
4. Build and run v2
docker build -t devopsdurga/myprojects:v2.0 .
docker run -d --name myprojects-v2 -p 8080:80 devopsdurga/myprojects:v2.0The original v1.0 tag remains available. You created a new image version rather than modifying a running container.
5. Verify
docker image ls devopsdurga/myprojects
docker exec myprojects-v2 pwd
curl http://localhost:8080Practice task
Change the heading in index.html, rebuild as v2.1, run it on a different host port and compare both versions.
Continue learning
Explore more practical DevOps and cloud tutorials in the Devops Init learning hub.
Back to learning hub →