- List Docker Images To verify that your image has been created successfully, you can list all Docker images:
- Run a Container from the Image To run a container based on your my-app image, use the docker run command:
In this command: -d runs the container in detached mode (in the background). --name my-app-container names the container my-app-container. -p 8080:8080 maps port 8080 on the host to port 8080 in the container (adjust as needed).
- Check Running Containers To see if your container is running, use:
This will list all currently running containers.
- Access the Running Container If you need to get a shell inside the running container, you can use docker exec:
- View Container Logs To view the logs of your running container, use:
- Stop and Remove the Container To stop the running container, use:
To remove the stopped container, use:
- Remove the Docker Image If you need to remove the Docker image, use:
- Clean Up Unused Images, Containers, Volumes, and Networks To clean up unused Docker objects, you can use: