docker 에 대해서

류지수·2023년 4월 9일
0

Docker란?

  • 컨테이너로 묶을 수 있는 하나의 컨테이너 가상화 "제품"입니다.
    - 컨테이너란?
    격리된 공간에서 프로세스가 동작하는 기술입니다. 즉, 하나의 운영 체제에서 다른 운영 체제를 가상화하지 않고, 어플리케이션을 실행하는데 필요한 모든 것을 패키지화하여 이식성이 높은 솔루션을 제공합니다.

Docker의 장점

  1. 가상화를 통해 환경을 신경 쓸 필요가 없다.
  2. 실행이 항상 보장되기 때문에 빠르게 필요한 프로그램을 빌드 할 수 있다.
  3. 복잡한 환경 구성을 할 필요 없이 간단하게 적용 할 수 있다

Docker의 구성

  • Docker Client: 사용자가 Docker를 사용하기 위해 입력하는 명령들을 전달하는 역할을 합니다.
  • Docker Daemon: Docker Client로부터 전달받은 명령을 수행하는 역할을 합니다.
  • Docker Image: 컨테이너를 생성하기 위해 필요한 파일들을 모아놓은 하나의 실행 파일입니다.
  • Docker Container: Docker Image를 기반으로 생성되며, 실제로 실행되는 컨테이너입니다. (프로그램의 입장에서 이미지: 클래스, 컨테이너: 인스턴스 로 이해하면 쉽습니다.)

간단한 Docker 명령어 실습

  • docker login
$docker login -u {username}
  • docker run

2-1) hello-world가 없는데 docker run hello-world

bash: docekr: command not found

2-2) hello-world가 없을 때 실행

docker run --name hello-world hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:6e8b6f026e0b9c419ea0fd02d3905dd0952ad1feea67543f525c73a0a790fefb
Status: Downloaded newer image for 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/
  • docker pull
$docker pull datawhales/fastapi-image:0.1.2 
(Image이름:버전)
  • docker images
$docker images

REPOSITORY                 TAG       IMAGE ID       CREATED         SIZE
fastapi                    v1        f9e231e056b3   6 weeks ago     938MB
mysql                      8         7484689f290f   3 months ago    538MB
  1. docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

docker ps -a

CONTAINER ID   IMAGE         COMMAND                  CREATED         STATUS                      PORTS                                         NAMES
1b02a9fcc07c   hello-world   "/hello"                 4 minutes ago   Exited (0) 4 minutes ago                                                  hello-world
bfa3341642d7   mysql:8       "docker-entrypoint.s…"   2 months ago    Exited (255) 6 weeks ago    3306/tcp, 33060/tcp, 0.0.0.0:3307->3307/tcp   mysql-tutorial
  • docker rm

6-1) containers 삭제시

docker rm

6-2) Image삭제시

docker rmi
profile
AI Engineer가 될테야

0개의 댓글