달력

3

« 2024/3 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'Linux'에 해당되는 글 2

  1. 2018.12.09 Docker 설치하기 - Docker Desktop MacOS (1)
  2. 2018.12.03 Visual Studio Code : Shortcuts(단축키)
2018. 12. 9. 23:00

Docker 설치하기 - Docker Desktop MacOS (1) Tip & Tips2018. 12. 9. 23:00

새로운 과제를 위해서 Docker의 사용을 검토하고 있는 와중에, 얼마전에는 Google Cloud 기반의 "Kubernates" 사용을 위한 교육도 참여하였다. 몇년전에 Docker에 대해서 검토할때도 각 Cloud 서비스를 제공하는 업체에서, 지금처럼 지원이 가능한 솔루션들이 많이 없었는데, 현재는 "Kubernates"를 기본 Docker관리 플랫폼으로 사용하려고 듯하다. "AWS", "MS" 그리고 "Google Cloud"에서 "Kubernates"를 지원한다.

구글에서는 컨테이너 기반으로 서비스를 운영하고 있다고 한다.


오늘은 며칠전부터 마음 먹었던 일을 하려고 한다. 개인용 PC에 도커를 설치해 보려고 한다. 집에서 사용하고 있는 MacOS에 설치하려고 한다.


Docker에 대해서는 며칠전부터 책을 보고 있는데, 나무위키에서는 다음과 같이 간단하게 잘 설명해 주고 있다.

도커는 LXC(리눅스 컨테이너)라는 커널 컨테이너 기술을 이용하여 만든 컨테이너 기술 중에 하나이다.


가상화와 관련된 여러 기술들이 있지만, 도커는 리눅스 기반의 기술에서 비롯되었다고 이해하면 된다.


Docker는 "https://www.docker.com"에 접속하면 자세한 정보들을 볼수 있는데, 나는 여기서 오늘은 MacOS에서 구동이 가능한 "Docker Desktop"을 설치하려고 한다.


Docker 웹사이트의 "Products" 메뉴에서 "Docker Desktop"을 찾아가거나 다음의 URL로 직접 접속해서 다운을 받아도 된다. 


Docker Desktop : https://www.docker.com/products/docker-desktop


아래와 같은 화면을 볼수 있을 것인데, 여기서 Mac용 설치 파일을 받으면 된다.





그런데, 바로 다운을 할수가 없다. ^^;;  

로그인을 위한 회원가입이 선행이 되어야 한다.

가입은 로그인 계정에 사용할 id와 인증을 위한 email 계정을 넣으면 쉽게 할수 있다. 인증 email을 받아서 내용을 보면, 아래와 같이 "Confirm Your Email" 버튼이 보이는데, 이를 클릭하면, 인증은 끝나고, 바로 다운로드를 받을 수 있다. 

MacOS 에서는 "Docker.dmg" 파일이 다운로드 받게 되어있다. 

이제 다운로드한 "Docker.dmg"을 Finder를 열고, 더블 클릭을 하게 되면 아래와 같은 화면이 나타나는데, 아래 창에서 보이는 그대로 "Docker" 이미지를 마우스로 드래그 & 드롭해서 "Applications"폴다 이미지에 가져다 놓으면 설치가 진행된다.

설치가 완료되고 실행을 시키면 아래와 같은 화면이 나타난다.

그리고 화면 상단에는 다음과 같이 도커 이미지가 표시가 될 것이다.



위 화면에서 "Next" 버튼을 누르면, 아래와 같이 권한에 대한 요청 메시지를 볼수 있는데, "OK"버튼을 클릭하고, 시스템 관련 Password를 입력하면 된다.

패스워드를 입력하면, 사용할 준비는 끝나게 되는데, 이와 동시에 화면 상단에 로그인 하라는 화면이 아래와 같이 나타날 것이다.

조금 아까 다운로드 받기위해서 만들었던,  id 와 password 를 입력하게 되면, 아래와 같이 사용이 가능하다는 화면이 나타나게 된다.

설치된 Docker Dasktop을 한번 테스트겸 사용해 보자.

간단하게 위의 화면처럼 Terminal을 하나 열고 "docker run hello-world"를 실행해 보자.

그러면 다음과 같이 화면에 표시가 될 것이다.

mymac$ docker run hello-world

Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world

d1725b59e92d: Pull complete 

Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788

Status: Downloaded newer image for hello-world:latest


Hello from Docker!

This message shows that your installation appears to be working correctly.


To generate this message, Docker took the following steps:

 1. The Docker client contacted the Docker daemon.

 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.

    (amd64)

 3. The Docker daemon created a new container from that image which runs the

    executable that produces the output you are currently reading.

 4. The Docker daemon streamed that output to the Docker client, which sent it

    to your terminal.


To try something more ambitious, you can run an Ubuntu container with:

 $ docker run -it ubuntu bash


Share images, automate workflows, and more with a free Docker ID:

 https://hub.docker.com/


For more examples and ideas, visit:

 https://docs.docker.com/get-started/


설치된 Docker의 버전은 "docker --version"을 이용해서 알수 있다.

mymac$ docker --version

Docker version 18.09.0, build 4d60db4


 이번에는 Webserver를 한번 띄우겠다. "docker run -d -p 80:80 --name webserver nginx" 라고 terminal에 입력한다.

mymac$ docker run -d -p 80:80 --name webserver nginx

Unable to find image 'nginx:latest' locally

latest: Pulling from library/nginx

a5a6f2f73cd8: Pull complete 

1ba02017c4b2: Pull complete 

33b176c904de: Pull complete 

Digest: sha256:5d32f60db294b5deb55d078cd4feb410ad88e6fe77500c87d3970eca97f54dba

Status: Downloaded newer image for nginx:latest

08f27af460e9d6d3521104729fdeda7f4fba9ff7b69187bbf7fb588307c4fc71


이미지가 로컬에 없다면, 다운받아서 설치가 될 것이다. 


설치된 이미지와 컨테이너의 동작을 보기 위해서 아래가 같이 "docker container ls" 명령은 준다. 

결과가 잘 나왔다.

mymac$ docker container ls

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES

08f27af460e9        nginx               "nginx -g 'daemon of…"   38 seconds ago      Up 37 seconds       0.0.0.0:80->80/tcp   webserver


이번에는 정상적으로 동작하는지 확인해 볼거다. Terminal에서 "curl -X GET http://localhost:80"을 입력하고 실행해보면 아래와 같이 출력이 될 것이다. 정상적으로 잘 동작하는 것이다. 물론 브라우저에서도 가능하다. 

mymac$ curl -X GET http://localhost:80

<!DOCTYPE html>

<html>

<head>

<title>Welcome to nginx!</title>

<style>

    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>



웹브라우저에서 "http://localhost" 또는 "http://localhost:80"을 실행해보면 다음과 같은 화면을 볼수 있을 것이다.




처음으로 docker dasktop을 설치해 보았는데, 설치는 별로 어렵지 않았는데, 로그인을 해야 한다라는 사실이 좀 생소하였다. 이후는 수월하게 설치할 수 있었다.


아참, 아까 띄워놓은 컨테이너는 어떻게하지, 아직도 동작하고 있을 텐데...

오늘은 늦었으니, 내일 다시 마무리 해야겠다.

 



:
Posted by 행복상자

Visual Studio Code의 단축키들을 정리한 파일들이다. 가끔식 확인이 필요하거나 책상에 프린트에서 붙여 놓으면, 참고하는데 도움이 될 것이다.  VS Code의 메뉴상에서는 "도움말" > "바로가기 키참조"에서 확인 가능하다.


아래는 각 OS별로 작성된 Shortcut 키 매핑에 대한 파일들의 링크와 위치이다.



[MacOS용 Shortcut 파일] 

   https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf






[Windows용 Shortcut 파일

    https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf





[Linux용 Shortcut 파일]

    https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf



:
Posted by 행복상자