728x90
Docker Image 삭제시 에러가 발생하는 경우가 있다.
technote@TechNote:~/docker$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
my-test-build latest 22b5185b193b 2 minutes ago 885MB
python 3 2a93c239d591 6 days ago 885MB
hello-world latest bf756fb1ae65 13 months ago 13.3kB
technote@TechNote:~/docker$ docker rmi bf756fb1ae65
Error response from daemon: conflict: unable to delete bf756fb1ae65 (must be forced) - image is being used by stopped container 83afae48b404
technote@TechNote:~/docker$
이는 삭제하려는 Image 가 container 로 사용되고 있어서 발생하는 것이기 때문에 해당 container 를 먼저 제거하고 Image 또한 삭제하면 된다.
technote@TechNote:~/docker$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
83afae48b404 hello-world "/hello" 2 weeks ago Exited (0) 2 weeks ago nostalgic_hofstadter
technote@TechNote:~/docker$ docker container rm 83afae48b404
83afae48b404
technote@TechNote:~/docker$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
technote@TechNote:~/docker$
해당 Container를 삭제하고 Image 를 삭제하면 아래와 같이 에러없이 삭제되는 것을 확인할 수 있다.
technote@TechNote:~/docker$ docker image ls -a
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> b7603defdd0d 6 minutes ago 885MB
my-test-build latest 22b5185b193b 6 minutes ago 885MB
python 3 2a93c239d591 6 days ago 885MB
hello-world latest bf756fb1ae65 13 months ago 13.3kB
technote@TechNote:~/docker$ docker image rm bf756fb1ae65
Untagged: hello-world:latest
Untagged: hello-world@sha256:31b9c7d48790f0d8c50ab433d9c3b7e17666d6993084c002c2ff1ca09b96391d
Untagged: hello-world@sha256:95ddb6c31407e84e91a986b004aee40975cb0bda14b5949f6faac5d2deadb4b9
Deleted: sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b
Deleted: sha256:9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63
technote@TechNote:~/docker$
technote@TechNote:~/docker$ docker image ls -a
REPOSITORY TAG IMAGE ID CREATED SIZE
my-test-build latest 22b5185b193b 6 minutes ago 885MB
<none> <none> b7603defdd0d 6 minutes ago 885MB
python 3 2a93c239d591 6 days ago 885MB
technote@TechNote:~/docker$
728x90