Skip to content

Latest commit

 

History

History
33 lines (31 loc) · 1.63 KB

docker-commands.adoc

File metadata and controls

33 lines (31 loc) · 1.63 KB

Common Docker Commands

Here is the list of commonly used Docker commands:

Purpose Command

Image

Build an image

docker build --rm=true .

Install an image

docker pull ${IMAGE}

List of installed images

docker images

List of installed images (detailed listing)

docker images --no-trunc

Remove an image

docker rmi ${IMAGE_ID}

Remove all untagged images

docker rmi $(docker images | grep “^” | awk “{print $3}”)

Remove all images

docker rm $(docker ps -aq)

Remove dangling images

docker rmi $(docker images --quiet --filter "dangling=true")

Containers

Run a container

docker run

List of running containers

docker ps

List of all containers

docker ps -a

Stop a container

docker stop ${CID}

Stop all running containers

docker stop docker ps -q

List all exited containers with status 1

docker ps -a --filter "exited=1"

Remove a container

docker rm ${CID}

Remove container by a regular expression

docker ps -a | grep wildfly | awk '{print $1}' | xargs docker rm -f

Remove all exited containers

docker rm -f $(docker ps -a | grep Exit | awk '{ print $1 }')

Remove all containers

docker rm $(docker ps -aq)

Find IP address of the container

docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${CID}

Attach to a container

docker attach ${CID}

Open a shell in to a container

docker exec -it ${CID} bash

Get container id for an image by a regular expression

docker ps | grep wildfly | awk '{print $1}'