Learn how to run a container using the hello-world image and manage containers and images.
docker run hello-worlddocker ps -a
it created and runs display message
Digest: sha256:a26bff933ddc26d5cdf7faa98b4ae1e3ec20c4985e6f87ac0973052224d24302
Status: Downloaded newer image for hello-world:latest
docker start [conatiner-name]docker rm [conatiner-name]docker rmi hello-worldRun an Ubuntu container in interactive mode, create a file inside it, and manage containers.
docker run -it ubuntumkdir rehab
cd rehab
vi hello-docker
in hello-docker i can write ant text
to check content
cat hello-dockerdocker stop [container-id-or-name] 7d56036d995b
docker rm [container-id-or-name] 7d56036d995bas ubuntu container is removed the file is removeddocker container prunedocker rm $(docker ps -a -q)
Create a custom Docker image using Nginx and a local HTML file.
mkdir nginx-custom
cd nginx-custom
nano index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2>Hello Docker</h2>
</body>
</html>
nano docker-file
# Use nginx
FROM nginx
# Copy the local HTML file
COPY index.html
docker build -t nginx-custom .
4. Test the Container, open your browser and navigate to http://localhost:8088 to check if everything is okay
docker run -d -p 8088:80 7d56036d995b custom-nginx nginx-custom