본문 바로가기
AI월드/⚙️AI BOOTCAMP_Section 3

docker 과제 다시풀어보기(part1,2,3)

by khalidpark 2021. 3. 13.

개인기록용
도커에 대한 개념이 명확하지 않아 과제를 다시 풀어보기로 했다


Part1

$ docker container run --rm -e S3S1N2_Name=박상원 -e github_username=khalidpark -i -t 이미지파일 bash

 

docker : 도커실행

container : 컨테이너 생성 (컨테이너에 들어와있는 상황이라면 제외)

run : 실행

--rm : 작업끝나면 container 제거

-e : 환경변수 설정

-i : Keep STDIN open even if not attached

-t : Allocate a pseudo-TTY

bash : 커맨드

 

docker run

docs.docker.com/engine/reference/commandline/run/

 

docker run

docker run: The `docker run` command first `creates` a writeable container layer over the specified image, and then `starts` it using the specified command. That is, `docker run` is equivalent...

docs.docker.com

* bash 커맨드는 어디서 알았니?

 


Part2

Docker Image 로 데이터베이스 환경 구성하기

 

1) $docker image pull 로 필요한 이미지 가져오기

2) $docker container run , 특정환경변수 반영한 컨테이너 실행

3) docker-compose.yaml 파일 작성 (파일 내 형식, 조건에 맞춰 2개의 이미지, 컨테이너에 대한 옵션값 저장 한 뒤)

4) $docker-compose up

5) 로컬호스트에서 작업 실행

 


Part3

도커 이미지 내 특정 파일을 로컬에 다운로드 할때

 

$docker save -o foo.tar image

foo.tar : 파일명
image : 이미지명

출처 : www.madebymikal.com/quick-hack-extracting-the-contents-of-a-docker-image-to-disk/

 

Quick hack: extracting the contents of a Docker image to disk – Made by Mikal

For various reasons, I wanted to inspect the contents of a Docker image without starting a container. Docker makes it easy to get an image as a tar file, like this: docker save -o foo.tar image But if you extract that tar file you’ll find a configuration

www.madebymikal.com

 

728x90

댓글