Docker ?

2017. 6. 27. 15:23CM/docker

반응형





 Docker?
  • 2013년 3월 Docker, Inc에서 출시한 오픈소스 컨테이너 프로젝트
  • 복잡한 리눅스 어플리케이션을 컨테이너로 묶어서 실행할 수 있음.
  • 리눅스 커널에서 제공하는 컨테이너 기술을 이용.
  • 컨테이너(이미지)를 전 세계 사람들과 공유
  • Github와 비슷한 방식의 Docker Hub 제공.
  • 이미지 생성과 배포에 특화.
    • 이미지 버전관리 제공, 중앙저장소에서 이미지를 올리고 받을 수 있음. (push/pull)

컨테이너?
  • 가상화보다 훨씬 가벼운 기술.
    • 가상머신 : 컴퓨터 안에서 컴퓨터를 만들어내기 위한 시도(1960년 대에 가상화 개념이 처음 등장)
      • 컴퓨터 통째로 만들어내다보니 각종 성능 손실이 발생. -> 리눅스 컨테이너 등장.
  • 컨테이너 안에 가상공간을 만들지만 실행 파일을 호스트에서 직접 실행.(리눅스 커널의 groups, namespaces가 제공하는 기술)



도커는 리눅스 컨테이너를 사용!
  • 초기에는 LXC(Linux Container)를 기반으로 구현.
  • 버전 0.9 부터는 LXC를 대신하는 libcontainer를 개발하여 사용.
  • 실행 옵션으로 선택 가능.

이미지와 컨테이너의 구분
  • 이미지 : 서비스 운영에 필요한 서버 프로그램
    • 소스코드, 컴파일된 실행 파일을 묶음 형태.
    • 저장소에 올리고 받는것은 이미지!(push/pull)
    • 이미지로 여러 개의 컨테이너를 만들수 있음.
  • 컨테이너 : 이미지를 실행한 상태!


도커 사용
docker + <명령>
예) docker run, docker push
* 항상 root 권한으로 실행.

  • docker hub에서 이미지 검색해보기
    • docker search <image name>
      • sudo docker search ubuntu
  • docker hub에서 이미지를 받아보자.
    • docker pull <image name>:<tag>
      • sudo docker pull ubuntu:latest
  • 모든 이미지를 출력해보기
    • docker images
      • sudo docker images
  • 이미지를 컨테이너로 생성한 뒤 Bash shell 실행해보기.
    • docker run <옵션> <이미지 이름> <실행할 파일>
      • sudo docker run -i -t —name hello ubuntu /bin/bash
      • -i : interactive / -t : passed-tty
        • 실행된 Bash 쉘에 입력 및 출력 가능.
      • —name : 컨테이너 이름을 지정. 미지정시 자동으로 이름을 생성하여 지정.
  • 모든 컨테이너 목록 출력
    • docker ps
      • sudo docker ps -a
  • 컨테이너 시작
    • docker start(restart) <컨테이너 이름>
      • sudo docker start hello
  • 방금 시작한 컨테이너에 접속해보기
    • docker attach <컨테이너 이름>
      • sudo docker attach hello
  • /bin/bash를 통하지 않고 외부에서 컨테이너 안의 명령 실행해보기
    • docker exec <컨테이너이름> <명령> <매개변수>
      • sudo docker exec hello echo “hello world”
  • 컨테이너 중지
    • docker stop <컨테이너 이름>
      • sudo docker stop hello
  • 컨테이너 삭제
    • docker rm hello
      • sudo docker rm hello
  • 이미지 삭제
    • docker rmi <이미지 이름>:<태그>
      • sudo docker rmi ubuntu:latest




Child commands

command의 링크를 누르시면 더 자세한 내용을 알수 있습니다.
CommandDescription
docker attachAttach local standard input, output, and error streams to a running container
docker buildBuild an image from a Dockerfile
docker checkpointManage checkpoints
docker commitCreate a new image from a container’s changes
docker configManage Docker configs
docker containerManage containers
docker cpCopy files/folders between a container and the local filesystem
docker createCreate a new container
docker deployDeploy a new stack or update an existing stack
docker diffInspect changes to files or directories on a container’s filesystem
docker eventsGet real time events from the server
docker execRun a command in a running container
docker exportExport a container’s filesystem as a tar archive
docker historyShow the history of an image
docker imageManage images
docker imagesList images
docker importImport the contents from a tarball to create a filesystem image
docker infoDisplay system-wide information
docker inspectReturn low-level information on Docker objects
docker killKill one or more running containers
docker loadLoad an image from a tar archive or STDIN
docker loginLog in to a Docker registry
docker logoutLog out from a Docker registry
docker logsFetch the logs of a container
docker manifestManage Docker image manifests and manifest lists
docker networkManage networks
docker nodeManage Swarm nodes
docker pausePause all processes within one or more containers
docker pluginManage plugins
docker portList port mappings or a specific mapping for the container
docker psList containers
docker pullPull an image or a repository from a registry
docker pushPush an image or a repository to a registry
docker renameRename a container
docker restartRestart one or more containers
docker rmRemove one or more containers
docker rmiRemove one or more images
docker runRun a command in a new container
docker saveSave one or more images to a tar archive (streamed to STDOUT by default)
docker searchSearch the Docker Hub for images
docker secretManage Docker secrets
docker serviceManage services
docker stackManage Docker stacks
docker startStart one or more stopped containers
docker statsDisplay a live stream of container(s) resource usage statistics
docker stopStop one or more running containers
docker swarmManage Swarm
docker systemManage Docker
docker tagCreate a tag TARGET_IMAGE that refers to SOURCE_IMAGE
docker topDisplay the running processes of a container
docker trustManage trust on Docker images
docker unpauseUnpause all processes within one or more containers
docker updateUpdate configuration of one or more containers
docker versionShow the Docker version information
docker volumeManage volumes
docker waitBlock until one or more containers stop, then print their exit codes


참고 사이트 : 


반응형

'CM > docker' 카테고리의 다른 글

Dockerfile 명령어 정리  (0) 2022.06.10
docker 빌드로 이미지를 만들어보자!(작성 중)  (0) 2022.01.25
Docker 리서치  (0) 2021.02.03
about docker  (0) 2017.04.27