FROM ubuntu:latest RUN apt-get update -y
docker build .
Get the image list
docker image ls
docker run -d -t --name mycontainer -p 3000:3000 <image_id>
, does the container exist? Then delete it first.
-t allows your container to be left running, usefull if you want to enter inside it for debugging purposes.
-p wires your network, useful to (re)direct traffic to your container. Imagine running a dockerized database and redirect traffic from your host to your docker container.
Stop the container
docker stop mycontainer
docker rm mycontainer
Else, just force and delete
docker rm --force mycontainer
To delete all containers
docker rm --force $(docker ps -a -f status=exited -q)
To delete all images
docker rmi --force $(docker images -a -q)
Sometimes theres a dependency between containers and images that prevents their removal. To solve it keep cycling the above two commands until all is cleaned.
docker container ls
List all event (+ stopped)
docker container ls --all
docker exec -ti mycontainer /bin/bash