본문으로 바로가기

Docker 기본 사용법

category Installation & Setting/docker 2019. 7. 25. 12:30
728x90

Docker Image

  • Docker는 기본적으로 image를 가지고 Container를 생성하기 때문에 Image를 먼저 다운로드 함
docker pull centos7:latest //centos7 image를 pull 받음
docker images //docker image 확인
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
docker.io/centos            latest              3fa822599e10        5 weeks ago         203.5 MB
  • Image를 삭제
docker rmi 3fa822599e10

Docker Container

  • Container 생성
docker run -it --name centos7 centos:latest bash //centos7 이라는 Docker Container 생성
docker start centos7
  • Container 확인
docker ps -a
  • Container 접근
docker exec -it centos7 bash
  • Container에 파일 복사
docker cp /home/source/test centos7:/root/dockertest
  • Container에 명령어 전달
docker exec -i -u 0 wizeyebase bash -c "chmod 777 /root/dockertest && cd /root"
  • Container 삭제
docker stop centos7
docker rm centos7

Docker Compose

  • docker container는 docker-compose.yaml 파일로 image를 다운받고 Container config를 설정 해줄 수 있음
  • docker-compose.yaml 파일이 있는 경로에서 다음 명령어를 실행해주면 됨
  • 해당 명령어는 신규 이미지가 있을 경우 업그레이드 할 때도 사용함
docker-compose -f docker-compose.yaml up -d

'Installation & Setting > docker' 카테고리의 다른 글

Docker Installation  (0) 2019.07.25
docker image Triger  (0) 2019.07.19