Docker images and containers management
Docker images and containers management
Here are a few commands to manage docker images and containers
Images
List all images:
docker image ls -a
Delete an image:
docker image rm IMAGE_NAME
Containers
Run a container:
docker run IMAGE_NAME
Here, the container will run in the foreground with a randomly assigned name
Run a container in the background:
docker run -d IMAGE_NAME
Run a container and give it a certain name:
docker run -n CONTAINER_NAME IMAGE_NAME
Stop a container (gracefully):
docker stop CONTAINER_NAME
Kill a container (ungraceful stop):
docker kill CONTAINER_NAME
List all containers, including those that are stopped:
docker container ls -a
Delete a container:
docker container rm CONTAINER_NAME
or
docker rm CONTAINER_NAME