...
코드개발
Dockerfile 생성
Dockerfile Image 생성
Container Orchestrator를 통한 배포
Container run
Container image Push
실습환경 구축 - VM 구성 테스트
정보 |
---|
이전의 모든 vagrant VM을 지우는 방법
이전의 모든 vagrant box를 지우는 방법
|
...
코드 블럭 |
---|
$mkdir -p ~/vagrant/ubuntu $cd ~/vagrant/ubuntu $vagrant init sysnet4admin/Ubuntu-k8s $vagrant up |
1. 기동 된 VM 확인
...
vagrant 명령어로 확인
$ vagrant box list
코드 블럭 $ vagrant ssh default Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.19.0-28-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s just raised the bar for easy, resilient and secure K8s cluster deployment. https://ubuntu.com/engage/secure-kubernetes-at-the-edge Last login: Sat Mar 20 18:04:46 2021 from 10.0.2.2 vagrant@k8s:~$
Docker 기본 명령어에 대해 알아보는 시간을 가지도록 하겠습니다.
...
2. Image 가져오기
docker image 저장소
...
: 기본 개념에서와 같이 도커는 저장소(registry)에서 이미지를 가져와 사용을 합니다.
코드 블럭 |
---|
vagrant@ubuntu-focal:~$ apt update vagrant@ubuntu-focal:~$ docker images |
...
vagrant@ubuntu-focal:~$ sudo -i |
...
root@ubuntu-focal:~# apt install docker.io |
...
| ||
코드 블럭 |
---|
docker hub 가입확인
정보 |
---|
docker 이미지 이름 구성 저장소 이름 (Repository Name) : default == docker hub |
$ docker pull nginx:latest
...
코드 블럭 |
---|
# docker ps 라는 명령어로 현재 실행중인 컨테이너를 확인합니다. # docker ps -a -> 중지된 컨테이너까지 모두 출력 root@ubuntu-focal:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
실행중인 컨테이너가 없네요
코드 블럭 |
---|
root@ubuntu-focal:~# docker run -it -d -p 80:80 --name=nginx nginx:latest |
...
root@ubuntu-focal:~# docker ps |
...
root@ubuntu-focal:~# curl http://localhost:80 |
설명>
코드 블럭 |
---|
# docker run 이라는 명령어로 컨테이너를 실행시켜줍니다. # docker run <옵션> <이미지 이름> <실행할 파일> root@ubuntu-focal:~# docker run -it -d -p 80:80 --name=nginx nginx:latest 1303feec17205609e6303e72831084babeaebdfaec3bf9bf0f6f4e4b39082dd1 # 옵션 -i(interactive), -t(Pseudo-tty) -> Bash Shell에 입력 및 출력을 할 수 있습니다. # 옵션 --name -> 컨테이너의 이름을 지정해 줍니다. # 옵션 -d -> daemonized # 옵션 -p -> 포트포워딩 ex) 80:80 = [호스트의 포트] : [컨테이너의 포트] root@ubuntu-focal:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1303feec1720 nginx:latest "/docker-entrypoint.…" 14 seconds ago Up 14 seconds 0.0.0.0:8080->80/tcp, :::8080->80/tcp nginx root@ubuntu-focal:~# curl http://localhost:80 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> |
...
정보 |
---|
Docker create : 도커 이미지에서 새로운 컨테이너를 생성합니다. 그러나 즉시 실행되지는 않습니다 Docker start : 중지된 컨테이너를 시작합니다. docker create 명령을 사용하여 컨테이너를 만든 경우 이 명령으로 시작할 수 있습니다. Docker run : create와 start의 조합으로 새 컨테이너를 생성하고 시작합니다. docker run 명령은 로컬 시스템에서 이미지를 찾지 못하는 경우 Docker Hub에서 이미지를 가져와서 컨테이너를 생성하고 실행합니다. |
...
코드 블럭 |
---|
root@ubuntu-focal:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mynginx 0.1 03de8991a4f8 11 minutes ago 178MB ubuntu 20.04 6df894023726 5 weeks ago 72.8MB root@ubuntu-focal:~# docker tag mynginx:0.1 mynginx:0.2 root@ubuntu-focal:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mynginx 0.1 03de8991a4f8 12 minutes ago 178MB mynginx 0.2 03de8991a4f8 12 minutes ago 178MB ubuntu 20.04 6df894023726 5 weeks ago 72.8MB root@ubuntu-focal:~# |
...
3. 컨테이너 Orchestration
Container Orchestration은 애플리케이션을 구성하고 있는 수십 또는 수백 개의 컨테이너와 호스트들을 배포하고 관리하기 위한 도구입니다.
...