To run our first Docker image terryalsdorf/devopshelloworld:latest, follow these steps:
First, you need to pull the Docker image from the Docker Hub repository to your local machine. You can do this using the docker pull command:
docker pull terryalsdorf/devopshelloworld:latest
Once you have the image locally, you can run it as a Docker container using the docker run command:
docker run -d -p 8080:80 terryalsdorf/devopshelloworld:latest
-d: Runs the container in detached mode (in the background).
-p 8080:80: Maps port 8080 on your host to port 80 in the container.
Now that the container is running, you can access your application by opening a web browser and navigating to http://localhost:8080. You should see the "Hello, World!" message from your Docker container.
When you're done testing, you can stop and remove the container using the following commands:
docker stop <container_id>
docker rm <container_id>
Replace <container_id> with the actual ID or name of the running container. You can find the container ID by running docker ps
That's it! You've successfully run your first Docker image as a container.