본문 바로가기

리눅스

[리눅스] docker commit 명령

728x90

docker commit 명령

 컨테이너를 이미지로 생성

docker commit 사용법

$ docker commit --help

Usage:  docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

Create a new image from a container's changes

Options:
  -a, --author string    Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")
  -c, --change list      Apply Dockerfile instruction to the created image
  -m, --message string   Commit message
  -p, --pause            Pause container during commit (default true)

컨테이너 이름 확인

docker ps

$ docker ps
CONTAINER ID  IMAGE       COMMAND                 CREATED            STATUS                       PORTS                   NAMES
b815d0d9a05f  registry:2  "/entrypoint.sh /etc…"  About an hour ago  Up About an hour (healthy)   0.0.0.0:5000->5000/tcp  registry

이미지 생성

docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

docker commit -a "anti1346" -m "registry web pakage update" registry-web anti1346/registry-web:1.0

$ docker commit -a "anti1346" -m "registry web pakage update" registry-web anti1346/registry-web:1.0
sha256:9a5e783291379b794d2facb26127747eb870ab1d08292ff8a9ca732642f4313a

이미지 이름 확인

docker images

$ docker images
REPOSITORY                              TAG       IMAGE ID       CREATED         SIZE
anti1346/registry-web                   1.0       9a5e78329137   7 minutes ago   1.02GB
hyper/docker-registry-web               latest    0db5683824d8   5 years ago     599MB

 

728x90