-
-
Save oreillyross/e8c745bee20bddaa008df59a7728343e to your computer and use it in GitHub Desktop.
docker run -d p <host-port>:<container-port> -e <name>=<value> <image-name> |
docker logs <unique id of docker image>
To run public docker images, you can search for them and then run them with the below command
docker run -p 27017:27107 mongo:latest
docker exec -it <container-id> bash
docker stop <container-id>
docker container list --all
docker rm <container-id>
Cleaning up everything all at once
Need a way to nuke all Docker containers and images at once? A few steps are
involved in doing this. The following commands work on macOS, Linux, and the WSL2
Linux terminal under Windows (but not under Windows Terminal).
First, stop and remove all containers:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
Then, run the prune command with the following options to remove everything else:
docker system prune --volumes --all
This will remove all cached images on your computer. Be prepared to wait a lot longer
for all subsequent Docker builds because it will download all the base images into your
local cache again.
docker container list