docker image

이상민·2023년 4월 13일
0

docker

목록 보기
4/19
post-thumbnail

image 확인

$ docker images
REPOSITORY                    TAG       IMAGE ID       CREATED       SIZE
gcr.io/k8s-minikube/kicbase   v0.0.39   67a4b1138d2d   12 days ago   1.05GB
mysql                         5.7       3f3447deacaa   2 weeks ago   455MB
nginx                         latest    080ed0ed8312   2 weeks ago   142MB
grafana/grafana               latest    a5c3d64d865c   4 weeks ago   329MB
ubuntu                        focal     1c5c8d0b973a   5 weeks ago   72.8MB

image 생성

$ docker run -it --name my_ubuntu ubuntu:focal
# ls
bin   dev  home  lib32  libx32  mnt  proc  run   srv  tmp  var
boot  etc  lib   lib64  media   opt  root  sbin  sys  usr
# cat > my_file
hello skybluelee~
^C

Ctrl + p + q 를 사용하면 container 종료 없이 ubuntu로 나갈 수 있음

# ubuntu@ip-172-31-26-111:~$ docker ps
CONTAINER ID   IMAGE          COMMAND       CREATED          STATUS          PORTS     NAMES
93ed5715a84f   ubuntu:focal   "/bin/bash"   45 seconds ago   Up 45 seconds             my_ubuntu

$ docker commit -a skybluelee -m "Add my file" my_ubuntu my-ubuntu:v1
sha256:a0a7635be6b5456046544074ea04d3f955bd9f0e13eb1ca406bfcd0bab06e5b4

$ docker images
REPOSITORY                    TAG       IMAGE ID       CREATED         SIZE
my-ubuntu                     v1        a0a7635be6b5   6 minutes ago   72.8MB
gcr.io/k8s-minikube/kicbase   v0.0.39   67a4b1138d2d   12 days ago     1.05GB
mysql                         5.7       3f3447deacaa   2 weeks ago     455MB
nginx                         latest    080ed0ed8312   2 weeks ago     142MB
grafana/grafana               latest    a5c3d64d865c   4 weeks ago     329MB
ubuntu                        focal     1c5c8d0b973a   5 weeks ago     72.8MB

my-ubuntu:v1 이미지가 생성되어 있음

$ docker rm -f my_ubuntu
my_ubuntu

$ docker run -i -t my-ubuntu:v1

# cat my_file
hello skybluelee~

container 종료 후에도 이미지에 접근 가능함.

dockerfile로 이미지 생성

/fastcampus-devops/3-docker-kubernetes/3-dockerfile/app$ ls
Dockerfile  package.json  spec  src  yarn.lock

$ cat Dockerfile
FROM node:12-alpine
RUN apk add --no-cache python3 g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]

fastcampus-devops/3-docker-kubernetes/3-dockerfile/app$ docker build -t my-app:v1 ./

$ docker images
REPOSITORY                    TAG       IMAGE ID       CREATED          SIZE
my-app                        v1        6c7508592ee6   8 minutes ago    408MB
my-ubuntu                     v1        a0a7635be6b5   49 minutes ago   72.8MB
gcr.io/k8s-minikube/kicbase   v0.0.39   67a4b1138d2d   12 days ago      1.05GB
mysql                         5.7       3f3447deacaa   2 weeks ago      455MB
nginx                         latest    080ed0ed8312   2 weeks ago      142MB
grafana/grafana               latest    a5c3d64d865c   4 weeks ago      329MB
ubuntu                        focal     1c5c8d0b973a   5 weeks ago      72.8MB

0개의 댓글