본문 바로가기

따배도 스터디

Docker 3-2 도커 컨테이너 살펴보기 실습편

728x90

docker 버젼 확인하는방법- sudo docker version

ubuntu@ip-내아이피야$sudo docker vers
Client: Docker Engine - Community
 Version:           23.0.3
 API version:       1.42
 Go version:        go1.19.7
 Git commit:        3e7cbfd
 Built:             Tue Apr  4 22:05:48 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          23.0.3
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.7
  Git commit:       59118bf
  Built:            Tue Apr  4 22:05:48 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.20
  GitCommit:        2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc:
  Version:          1.1.5
  GitCommit:        v1.1.5-0-gf19387a
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

1.Docker Hub에서 컨테이너 이미지 검색

 

root@ip-172-31-45-232:/home/ubuntu# docker search nginx
NAME                                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                                             Official build of Nginx.                        18356     [OK]
bitnami/nginx                                     Bitnami nginx Docker Image                      157                  [OK]
bitnami/nginx-ingress-controller                  Bitnami Docker Image for NGINX Ingress Contr…   23                   [OK]
ubuntu/nginx                                      Nginx, a high-performance reverse proxy & we…   84
kasmweb/nginx                                     An Nginx image based off nginx:alpine and in…   4
rancher/nginx-ingress-controller                                                                  11
rancher/nginx-ingress-controller-defaultbackend                                                   2
bitnami/nginx-exporter                                                                            3
rancher/nginx                                                                                     2
rapidfort/nginx-ib                                RapidFort optimized, hardened image for NGIN…   0
rapidfort/nginx                                   RapidFort optimized, hardened image for NGINX   3
vmware/nginx-photon                                                                               1
bitnami/nginx-ldap-auth-daemon                                                                    3
rapidfort/nginx-official                          RapidFort optimized, hardened image for NGIN…   1
vmware/nginx                                                                                      2
rancher/nginx-conf                                                                                0
linuxserver/nginx                                 An Nginx container, brought to you by LinuxS…   189
privatebin/nginx-fpm-alpine                       PrivateBin running on an Nginx, php-fpm & Al…   72                   [OK]
bitnami/nginx-intel                                                                               1
rancher/nginx-ssl                                                                                 0
circleci/nginx                                    This image is for internal use                  2
continuumio/nginx-ingress-ws                                                                      0
rancher/nginx-ingress-controller-amd64                                                            0
webdevops/nginx                                   Nginx container                                 11                   [OK]
clearlinux/nginx                                  Nginx reverse proxy server with the

2.컨테이너 이미지 다운로드 후 image layer 보기

앞서 docker 컨테이너 이미지 layer가 들어가는 저장소가 어딘지 알아보자

root 계정의 /var/lib/docker 안에있는 overlay2에 이미지 layer가 저장된다.

 

3.docker pull nginx 명령어를 통해 nginx 이미지 다운로드!

 

root@ip-172-31-45-232:/var/lib/docker/overlay2# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
f1f26f570256: Pull complete
7f7f30930c6b: Pull complete
2836b727df80: Pull complete
e1eeb0f1c06b: Pull complete
86b2457cc2b0: Pull complete
9862f2ee2e8c: Pull complete
Digest: sha256:2ab30d6ac53580a6db8b657abf0f68d75360ff5cc1670a85acb5bd85ba1b19c0
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
root@ip-172-31-45-232:/var/lib/docker/overlay2# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    080ed0ed8312   11 days ago   142MB

4.docker /var/lib/docker/overlay2에 다음과 같이 ningx 이미지 layer 가 저장됨

root@ip-172-31-45-232:/var/lib/docker/overlay2# ls
05940f5c5f3ceff4c5167e7e8f7c0c535c42ee095e9c77e75d437daa40dde800
80c261b7cf14c6d44ebd578e0558b72722ece0c00c60b0b63621ecedea3c7a6c
99a7b3295b37ea37629d38a1a3f2ad4d556edc5c960ce424f2fad47f5341cf58
ae7530c0d1825913d9b31840f09662f6797d2ebae6f8b0509e2c15340776ed10
b98c688327249e5f0e69ecccca7ea6f054bfcf72e51acd11c5564fc6c21ee669
f77b1f253be8eeaa0bc8ced805570784d23425ff4823ec11804ebada6a8c69d2

도커실행 - docker run --name web -d -p 80:80 niginx

-p옵션은 호스트의 80번 포트와 컨테이너의 80번 포트를 연결하는 역할을 합니다

root@ip-172-31-45-232:/var/lib/docker/overlay2# docker run --name web -d -p 80:80 ngi          nx
22fda5e4e6d8c2e19a531c22fcc70fca1db85992e9599f32cd2a0b873fe22e54

5.동작시킨 Nginx서버에 접속해보자!

일단 AWS 보안그룹에 80포트를 열어주겠습니다

보안그룹 탭 클릭 

인바드운 규칙편집 클릭
80포트를 누구나 들어올수있게 anytwhere로 설정 후 열어줍니다.

설정 후 나의 퍼플리주소의 80포트로 접속하게되면 다음과 같이 Nginx 서버에 접속 가능합니다.

728x90