'How to clean created docker image on self hosted server?
I have a pipeline on azure platform that builds the image of my application and pushed the docker hub.
The steps are:
- stage: DockerizeApp
condition: succeeded()
displayName: Dockerize App
jobs:
- job: BuildDockerImage
displayName: Build Docker Image Job
steps:
- task: Docker@2
displayName: Build Docker Image
inputs:
repository: $(imageName)
command: build
dockerFile: '**/Dockerfile'
tags: "latest"
- job: PushDockerImage
displayName: Push Docker Image Job
dependsOn: BuildDockerImage
condition: succeeded()
steps:
- task: Docker@2
displayName: Push Image
inputs:
containerRegistry: $(dockerHub)
repository: $(imageName)
command: push
tags: "latest"
Build step creates a new image and adds it to my docker images named app/xyz:latest. But all build creates a new image on my computer. The old ona is tagged as <none>. So how can I clean images after push it to docker hub?
Solution 1:[1]
To clean up all unused or dangling images, containers, volumes, and networks, you can try the following command lines.
Remove any images, containers, volumes, and networks that are dangling (not tagged or associated with a container).
docker system pruneRemove any stopped containers and all unused images (not just dangling images), add the
-aflag to the command.docker system prune -a
For more details, you can reference the following articles:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
