[Docker] docker 이미지 삭제 시 에러 발생할 때
docker 테스트 중에 이미지 삭제가 안된다!
#도커 테스트 (이미지 다운)
[minggu92@cloud ~]$ docker container run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
2db29710123e: Pull complete
Digest: sha256:4c5f3db4f8a54eb1e017c385f683a2de6e06f75be442dc32698c9bbe6c861edd
Status: Downloaded newer image for docker.io/hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
#도커 이미지 리스트
[minggu92@cloud ~]$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/hello-world latest feb5d9fea6a5 5 months ago 13.3 kB
이미지를 다운로드 받아 설치되는 것을 확인했다.
그리고 이 이미지를 지우려고 하는데 에러가 발생했다.
#도커 이미지 삭제
# or docker rmi [imageID]
[minggu92@cloud ~]$ docker image rm hello-world
Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - containe r b45b011652be is using its referenced image feb5d9fea6a5
해당 이미지를 참조하는 컨테이너를 확인해보자.
# 도커 컨테이너 리스트 확인
# or docker ps -a
[minggu92@cloud ~]$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f71ee345bd6a hello-world "/hello" 5 minutes ago Exited (0) 5 minutes ago dreamy_borg
b45b011652be hello-world "/hello" 20 minutes ago Exited (0) 20 minutes ago vibrant_yonath
bee4165d53b0 hello-world "/hello" 28 minutes ago Exited (0) 28 minutes ago competent_mirzakhani
현재 3개의 컨테이너가 이 이미지를 참조하고 있다.
따라서 해당 컨테이너들을 먼저 지워줘야 한다.
#도커 컨테이너 삭제
[minggu92@cloud ~]$ docker container rm dreamy_borg
dreamy_borg
[minggu92@cloud ~]$ docker container rm vibrant_yonath
vibrant_yonath
[minggu92@cloud ~]$ docker container rm competent_mirzakhani
competent_mirzakhani
#도커 이미지 삭제
[minggu92@cloud ~]$ docker image rm hello-world
Untagged: hello-world:latest
Untagged: docker.io/hello-world@sha256:4c5f3db4f8a54eb1e017c385f683a2de6e06f75be442dc32698c9bbe6c861edd
Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412
Deleted: sha256:e07ee1baac5fae6a26f30cabfe54a36d3402f96afda318fe0a96cec4ca393359
[minggu92@cloud ~]$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
하지만 더 편하게 전체 종료하는 방법이 있으니 다음 글을 보도록 하자!
https://minggu92.tistory.com/70
'Server & Infra' 카테고리의 다른 글
[Docker] docker container ssh 설치 및 접속 (0) | 2022.03.17 |
---|---|
[Docker] Docker Container 조작 총정리 (0) | 2022.03.17 |
[Docker] sudo 권한 없이 Docker 실행 (0) | 2022.03.16 |
[Docker] yum 명령어를 통한 Docker 설치방법 (Cloud 환경) (0) | 2022.03.11 |
[Linux / CentOS 7] vmware 리눅스 하드디스크 마운트 및 폴더 용량 확장 (3) | 2021.11.08 |