Docker images management

How to build and manage docker images

view on github

Docker image commands

✔️ List all images

docker image ls -a

✔️ Delete image (specified, all unused by at least 1 container)

# delete a specific image
docker image rm <image>

# delete all images not used by at least 1 container
docker image prune -f

✔️ Create new image

# build image according to current directory's Dockerfile
docker build -t <image> . 

Docker registry commands

✔️ Log in this CLI session using your Docker credentials (TTY terminal only, use CMD and not BASH)

# important : does not work on pseudo-TTY, it is thus impossible to login through SSH
# authenticating to a docker registry requires a real TTY and direct access to the machine
docker login      

✔️ Tag <image> for upload to the configured registry

# username is mandatory to avoid collision with similarly named images
docker tag <image> username/repository:tag  

✔️ Upload tagged image to the configured registry

# username is mandatory to avoid collision with similarly named images
docker push username/repository:tag     

✔️ Pull image from the configured registry

# pull image locally
docker pull <image>

# pull image and run CMD/ENTRYPOINT Dockerfile directive
docker container run username/repository:tag