카테고리 없음
[Docker] 도커 개념 및 hello-world 이미지를 받아 컨테이너로 실행하기
Black.bean
2020. 5. 16. 14:32
기본 배경
1. Jupyter Notebook 설치
인스턴스로 생성된 OS를 웹브라우저환경에서 수행한다. (필자는 putty를 이용하여 서버에 접속할 예정)
$ sudo apt-get update
% sudo apt-get install python3-pip
$ sudo pip3 install notebook
2. Docker
다양한 컨테이너를 이미지의 형태로 저장한다. 이미지를 다운로드 받아 서버의 이전, 확장을 손쉽게하는 가상화 소프트웨어이다. OS에 관계 없이 도커 엔진 위에서 프로그램을 실행할 수 있다.
Install Docker Engine on Ubuntu
docs.docker.com
우분투 버전마다 다르므로 위 공식문서를 참조하는게 좋다.
sudo apt update
sudo apt install apt-transport-https
sudo apt install ca-certificates
sudo apt install curl
sudo apt install software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
여기까지 하면 apt-list에 docker를 다운로드 받을 수 있게 된다.
sudo apt-cache policy docker-ce
sudo apt install docker-ce
도커를 설치하면 시스템 서비스로 자동으로 등록된다. 아래 코드로 도커가 구동중인지 확인된다.
실습
1. hello-world 이미지를 pull로 다운받기
docker pull hello-world
2. 다운받은 이미지를 run을 시용하여 실제 컨테이너로 띄우기
docker run hello-world
위 출력 결과를 보면 그냥 프린트 결과 밖에 업어서 뭔지 모를 수도 있다.
하지만 실제로는 현재 Instance 서버 위에 또 다른 서버가 pull, run 명령어 만으로 생성된 것이다.
2.1 수행된 컨테이너 확인 명령어 ps- a
2.2 hello-world 컨테이너를 container id를 이용하여 삭제하기
docker rm "삭제할 컨테이너 ID"
위는 컨테이너가 삭제된 것이다. 이미지는 다시 run을 이용하며 컨테이너로 만들 수 있다.