<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux &#8211; WONIZZ.LOG</title>
	<atom:link href="https://blog.wonizz.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.wonizz.com</link>
	<description>AI 자동화를 직접 굴려 본 개발자의 실무 교훈</description>
	<lastBuildDate>Fri, 16 Oct 2026 10:09:43 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/08/wz-siteicon-512.png?fit=32%2C32&#038;ssl=1</url>
	<title>Linux &#8211; WONIZZ.LOG</title>
	<link>https://blog.wonizz.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">152411368</site>	<item>
		<title>[Docker] Compose 구성과 사용법</title>
		<link>https://blog.wonizz.com/2019/08/13/docker-compose/</link>
					<comments>https://blog.wonizz.com/2019/08/13/docker-compose/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Tue, 13 Aug 2019 02:37:51 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[도커]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=731</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈입니다. 오늘은 docker의 compose구성법에 대해서 정리를 해보려고 합니다. 만약 여러분이 앱컨테이너와 데이터베이스 컨테이너의 실행 순서를 지켜서 실행해야한다고 생각해보세요. 반드시 데이터베이스 컨테이너를 실행한 다음에 앱 컨테이너를 실행해야 합니다. 그렇지 않으면 앱 컨테이너에서 데이터베이스 컨테이너를 찾을 수 없기 때문이죠. 깜박하고 앱 컨테이너부터 실행했다면? 종료하고 데이터베이스 컨테이너 실행하고, 다시 앱 컨테이너를 실행하는 불편함이 있죠. 도커&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/13/docker-compose/">[Docker] Compose 구성과 사용법</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
안녕하세요? 정리하는 개발자 워니즈입니다. 오늘은 docker의 compose구성법에 대해서 정리를 해보려고 합니다.
 만약 여러분이 앱컨테이너와 데이터베이스 컨테이너의 실행 순서를 지켜서 실행해야한다고 생각해보세요. 반드시 데이터베이스 컨테이너를 실행한 다음에 앱 컨테이너를 실행해야 합니다. 그렇지 않으면 앱 컨테이너에서 데이터베이스 컨테이너를 찾을 수 없기 때문이죠. 깜박하고 앱 컨테이너부터 실행했다면? 종료하고 데이터베이스 컨테이너 실행하고, 다시 앱 컨테이너를 실행하는 불편함이 있죠.

<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/08/DC_main.jpg?w=1200&#038;ssl=1" alt="Docker Compose 구성과 사용법 설명 이미지 1" />

도커 컴포즈를 사용하면 컨테이너 실행에 필요한 옵션을 docker-compose.yml이라는 파일에 적어둘 수 있고, 컨테이너 간 실행 순서나 의존성도 관리할 수 있습니다.

<h2>1. docker-compose.yml 파일</h2>

docker-compose.yml은 장황한 도커 실행 옵션을 미리 적어둔 문서라고 볼 수 있습니다. 프로젝트 루트에 파일을 만들고, 다음 내용을 붙여 넣습니다.

<pre><code class="line-numbers">version: '3'

services:
  db:
    image: postgres
    volumes:
      - ./docker/data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=sampledb
      - POSTGRES_USER=sampleuser
      - POSTGRES_PASSWORD=samplesecret
      - POSTGRES_INITDB_ARGS=--encoding=UTF-8

  django:
    build:
      context: .
      dockerfile: ./compose/django/Dockerfile-dev
    environment:
      - DJANGO_DEBUG=True
      - DJANGO_DB_HOST=db
      - DJANGO_DB_PORT=5432
      - DJANGO_DB_NAME=sampledb
      - DJANGO_DB_USERNAME=sampleuser
      - DJANGO_DB_PASSWORD=samplesecret
      - DJANGO_SECRET_KEY=dev_secret_key
    ports:
      - "8000:8000"
    command: 
      - python manage.py runserver 0:8000
    volumes:
      - ./:/app/
</code></pre>

이제 한줄씩 확인해보면서 정리 하도록 해보겠습니다.

<ol>
<li>version

<pre><code class="line-numbers">version: '3'
</code></pre>

docker-compose.yml 파일의 첫 줄에는 파일 규격 버전을 적습니다. 파일의 규격에 따라 지원하는 옵션이 달라지는데, “3”이라만 적으면 3으로 시작하는 최신 버전을 사용한다는 의미입니다. (파일 규격 버전에 따른 자세한 내용은 compose 파일의 버전과 호환성을 안내한 공식 문서를 참고하세요.)</p></li>
<li>services

<pre><code class="line-numbers">services:
</code></pre>

이 항목 밑에 실행하려는 컨테이너들을 정의합니다. 컴포즈에서는 컨테이너 대신 서비스라는 개념을 사용합니다.</p></li>
<li>db

<pre><code class="line-numbers">services:
 db:
</code></pre>

postgres 서비스의 이름을 db로 정하였습니다.</p></li>
<li>image

<pre><code class="line-numbers">services:
 db:
   image: postgres
</code></pre>

db 서비스에서 사용할 도커 이미지를 적습니다. 여기서는 dockerhub의 공식 postgres 이미지를 사용하였습니다.</p></li>
<li>volumes

<pre><code class="line-numbers">services:
 db:
   volumes:
     - ./docker/data:/var/lib/postgresql/data
</code></pre>

docker run으로 db 컨테이너를 실행할 때 &#8211;volume 옵션을 사용하여 데이터베이스의 데이터를 로컬 컴퓨터에 저장했던 부분과 같습니다. 다만 docker-compose.yml의 volumes에는 상대 경로를 지정할 수 있어서 편리합니다.

docker run으로 db 컨테이너를 실행할 때와 마찬가지로, 프로젝트 루트 아래의 docker/data 디렉터리에 데이터를 저장하기로 했습니다.</p></li>
<li>environment

<pre><code class="line-numbers">services:
 db:
   environment:
     - POSTGRES_DB=sampledb
     - POSTGRES_USER=sampleuser
     - POSTGRES_PASSWORD=samplesecret
     - POSTGRES_INITDB_ARGS=--encoding=UTF-8
</code></pre>

docker run 명령어의 -e 옵션에 적었던 내용들입니다. 마지막의 POSTGRES_INITDB_ARGS 부분이 추가되었는데, 데이터베이스 서버의 인코딩을 UTF-8로 설정하기 위함입니다.</p></li>
<li>django

<pre><code class="line-numbers">services:
 django:
</code></pre>

앱 서비스의 이름은 django로 지정하였습니다.</p></li>
<li>build

<pre><code class="line-numbers">services:
 django:
   build:
     context: .
     dockerfile: ./compose/django/Dockerfile-dev
</code></pre>

db 서비스와 달리 앱 서비스는 특정 이미지 대신 build 옵션을 추가합니다.

context는 docker build 명령을 실행할 디렉터리 경로라고 보시면 됩니다.

dockerfile에는 ‘개발용’ 도커 이미지를 빌드하는 데 사용할 Dockerfile을 지정하면 됩니다. Dockerfile-dev 파일에서는 (운영용 Dockerfile과는 달리) 소스코드를 컨테이너에 넣지 않습니다.</p></li>
<li>ports

<pre><code class="line-numbers">services:
 django:
   ports:
     - "8000:8000"
</code></pre>

docker run 명령어의 -p 옵션에 해당하는 부분입니다.</p></li>
<li><p>command

<pre><code class="line-numbers">services:
  django:
    command:
      - python manage.py runserver 0:8000
</code></pre>

docker run으로 앱 컨테이너를 실행할 때 가장 마지막에 적었던 명령어 부분입니다.</p></li>
</ol>

<h2>2. 도커 컴포즈의 주요 명령어</h2>

<ul>
<li>up -d</li>
</ul>

<pre><code class="line-numbers">docker-compose.yml 파일의 내용에 따라 이미지를 빌드하고 서비스를 실행합니다. 자세한 진행 과정은 다음과 같습니다.
</code></pre>

<p>서비스를 띄울 네트워크 설정
필요한 볼륨 생성(혹은 이미 존재하는 볼륨과 연결)
필요한 이미지 풀(pull)
필요한 이미지 빌드(build)
서비스 의존성에 따라 서비스 실행
up 명령에 사용할 수 있는 몇 가지 옵션도 존재합니다.

-d: 서비스 실행 후 콘솔로 빠져나옵니다. (docker run에서의 -d와 같습니다.)
&#8211;force-recreate: 컨테이너를 지우고 새로 만듭니다.
&#8211;build: 서비스 시작 전 이미지를 새로 만듭니다.

<ul>
<li>ps</li>
</ul>

현재 환경에서 실행 중인 각 서비스의 상태를 보여줍니다.

<pre><code class="line-numbers">$ docker-compose ps
        Name                       Command               State           Ports
--------------------------------------------------------------------------------
djangosample_db_1       /docker-entrypoint.sh postgres   Up      5432/tcp
djangosample_django_1   /bash -c python manage.py        Up      0.0.0.0:8000->8000/tcp
</code></pre>

<ul>
<li>stop, start</li>
</ul>

서비스를 멈추거나, 멈춰 있는 서비스를 시작합니다.

<pre><code class="line-numbers">$ docker-compose stop
Stopping djangosample_django_1 ...
Stopping djangosample_db_1 ...

$ docker-compose start
Starting db ... done
Starting django ... done
</code></pre>

<ul>
<li>down</li>
</ul>

서비스를 지웁니다. 컨테이너와 네트워크를 삭제하며, 옵션에 따라 볼륨도 지웁니다.

<pre><code class="line-numbers">$ docker-compose down --volume
Removing myproject_django_1 ... done
Removing myproject_db_1 ... done
Removing network djangosample_default
Removing volume django_sample_db_dev
</code></pre>

&#8211;volume: 볼륨까지 삭제합니다.

<ul>
<li>exec</li>
</ul>

실행 중인 컨테이너에서 명령어를 실행합니다. 자동화된 마이그레이션용 파일 생성이나 유닛 테스트, lint 등을 실행할 때 사용합니다.*

<ul>
<li>비슷한 명령으로 run이 존재합니다. run은 새 컨테이너를 만들어서 명령어를 실행합니다. docker run과 마찬가지로 &#8211;rm 옵션을 추가하지 않으면, 컨테이너가 종료된 후에도 삭제되지 않습니다. (이런 이유 때문에 개인적으로는 exec를 선호하지만, 컨테이너에서 추천하는 방식은 사실 run입니다.)</li>
</ul>

<pre><code class="line-numbers">$ docker-compose exec django ./manage.py makemigrations
...
$ docker-compose exec node npm run test
> expresssample@0.1.0 test /www/service
> mocha $(find test -name '*.spec.js')
...
</code></pre>

<ul>
<li>logs</li>
</ul>

서비스의 로그를 확인할 수 있습니다. logs 뒤에 서비스 이름을 적지 않으면 도커 컴포즈가 관리하는 모든 서비스의 로그를 함께 보여줍니다.

<pre><code class="line-numbers">$ docker-compose logs django
Attaching to djangosample_django_1
django_1     | System check identified no issues (0 silenced).
django_1     | February 13, 2017 - 16:32:28
django_1     | Django version 1.10.4, using settings 'djangosample.settings'
django_1     | Starting development server at http://0.0.0.0:8000/
django_1     | Quit the server with CONTROL-C.
</code></pre>

-f: 지금까지 쌓인 로그를 다 보여준 후에도 셸로 빠져나오지 않고, 로그가 쌓일 때마다 계속해서 출력합니다.

<h2>3. 예시</h2>

필자에게 업무중 주어진 미션이 각종 tool 들을 업그레이드 버전으로 설치하는 것이였다. 그런데 리눅스를 다뤄보신 분들은 알겠지만, 업그레이드라는게 yum 으로 쉽사리 설치가 되면 좋겠지만 각종 설정 파일들부터 복원 계획도 다 갖고 있어야 한다.

필자의 프로젝트에서는 grafana, zabbix, rundeck, kibana, eleasticsearch 등 다양한 도구들을 활용하고 있는데, 업그레이드를 하면서 지속적으로 기존 시스템에 영향을 주지 않는 범위내에서 해보고 싶었고, docker가 제격이라고 생각하게 되었다.

다음의 시나리오대로 grafana를 업그레이드 해봤습니다.

<ol>
<li>기존 파일 백업

<pre><code class="line-numbers">- /var/lib/grafana 경로에서 데이터 백업
cp -r grafana grafana_bak 

그라파나의 데이터베이스 경로
</code></pre></li>
<li>도커 컨테이너 실행

공식 문서에 보면, 다음과 같이 도커를 실행하라고 명시되어있다.

<pre><code class="line-numbers">$ docker run \
 -d \
 -p 3000:3000 \
 --name=grafana \
 -e "GF_SERVER_ROOT_URL=http://grafana.server.name" \
 -e "GF_SECURITY_ADMIN_PASSWORD=secret" \
 grafana/grafana
</code></pre>

위의 명령어를 보시면 알겠지만,

-d : 데몬(백그라운드) 실행

-p : 포트 포워딩

&#8211;name : 컨테이너 네임 명시

-e : 환경 변수 : 그라파나 configure에 명시되어있어서 없어도도.ㅁ

grafana/grafana : 이미지 명시 (최신 이미지 가져옴) -> grafana/grafana:5.1.0 특정 버전 명시가능

필요한 플러그인 업데이트

*실제로 설치하고 난뒤, Zabbix plugin for Grafana 가 에러가 발생하여, 컨테이너 내부에서 업데이트를 하였습니다

<pre><code class="line-numbers">grafana-cli plugins install <plugin-id>
</code></pre></li>
<li>컴포즈 구성으로 변경

<pre><code class="line-numbers">version: "2.1"
services:
 grafana:
     image: grafana
     restart: always
     container_name: grafana
     volumes:
       - "/var/lib/grafana:/var/lib/grafana"
     expose:
       - 3000
     ports:
       - "3000:3000"
</code></pre>

위의 docker 명령어를 명시해 놓은 compose 파일로 간단하게 실행이 가능합니다.

</li>
<li>

컨테이너 실행

<pre><code class="line-numbers">docker-compose up -d
</code></pre>

<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/08/DC_example.jpg?w=1200&#038;ssl=1" alt="Docker Compose 구성과 사용법 설명 이미지 2" />

</li>
</ol>

<a href="http://blog.wonizz.com" title="블로그 워니즈">블로그 워니즈</a>
<a href="http://github.com/wonizz" title="워니즈 블로그" target="_blank" rel="noopener">워니즈 블로그</a>
<h2 class="wp-block-heading">함께 보면 좋은 글</h2>
<ul class="wp-block-list"><li><a href="https://blog.wonizz.com/2019/07/31/docker-dockerfile/">[Docker] Dockerfile 의 이해</a></li><li><a href="https://blog.wonizz.com/2019/07/29/docker-volume/">[Docker] Volume 의 관리</a></li><li><a href="https://blog.wonizz.com/2019/07/27/docker-network/">[Docker] 네트워크의 이해</a></li><li><a href="https://blog.wonizz.com/2019/08/08/ansible-role-include/">[Ansible] 플레이북 Role 과 Include</a></li></ul>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/13/docker-compose/">[Docker] Compose 구성과 사용법</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/08/13/docker-compose/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">731</post-id>	</item>
		<item>
		<title>[Ansible] 앤서블 Jinja2 필터 사용법</title>
		<link>https://blog.wonizz.com/2019/08/09/ansible-jinja2/</link>
					<comments>https://blog.wonizz.com/2019/08/09/ansible-jinja2/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Fri, 09 Aug 2019 05:44:06 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[DevOps]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=727</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다. 필자가 갑자기 Ansible을 너무 재밌게 하고 있어서 당분간 Ansible 연재를 계속 할 것 같습니다. 지난시간까지는 간단한 playbook 사용법에 대해서 알아봤는데요. 이번시간에는 데이터 변경작업에 대한 이야기를 해보려고 합니다. Ansible은 보면 템플릿을 잘 활용해야되는데요. 그안에서 데이터를 적절히 조작해서 필요한 작업을 진행할 수 있습니다. Jinja2 필터는 템플릿에서 데이터를 어떤 형태에서 다른 형태로 바꾸는&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/09/ansible-jinja2/">[Ansible] 앤서블 Jinja2 필터 사용법</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
안녕하세요? 정리하는 개발자 워니즈 입니다. 필자가 갑자기 <code>Ansible</code>을 너무 재밌게 하고 있어서 당분간 <code>Ansible</code> 연재를 계속 할 것 같습니다. 지난시간까지는 간단한 <code>playbook</code> 사용법에 대해서 알아봤는데요. 이번시간에는 데이터 변경작업에 대한 이야기를 해보려고 합니다.

<code>Ansible</code>은 보면 템플릿을 잘 활용해야되는데요. 그안에서 데이터를 적절히 조작해서 필요한 작업을 진행할 수 있습니다.

<img data-recalc-dims="1" decoding="async" src="https://rajputhimanshu.files.wordpress.com/2018/02/jinja.jpg?resize=539%2C249&#038;w=1200" alt="Ansible 앤서블 Jinja2 필터 사용법" />

Jinja2 필터는 템플릿에서 데이터를 어떤 형태에서 다른 형태로 바꾸는 작업입니다. 이미 많은 <a href="http://jinja.pocoo.org/docs/templates/#builtin-filters" target="_blank" rel="noopener">내장 함수</a>를 가지고 있습니다. 이런 필터 기능은  로컬 데이터를 다루는 Ansible의 컨트롤러에서 수행되는 것이며 타겟 머신의 태스크에서 이루어 지는 것이 아닙니다.

<h2>1. 기본 예제</h2>

<ul>
<li>데이터 포맷을 위한 필터</li>
</ul>

어떤 결과를 다른 형태로 변경하는 것입니다. 디버깅을 할 때 유용한 경우가 있습니다.

<pre><code class="line-numbers">{{ some_variable | to_json }}
{{ some_variable | to_yaml }}
</code></pre>

또는 사람이 읽기 쉬운 형태로 출력을 합니다.

<pre><code class="line-numbers">{{ some_variable | to_nice_json }}
{{ some_variable | to_nice_yaml }}
</code></pre>

파이썬의 pprint 모듈처럼 indent를 줄 수도 있습니다. (버전 2.2 이후)

<pre><code class="line-numbers">{{ some_variable | to_nice_json(indent=2) }}
{{ some_variable | to_nice_yaml(indent=8) }}
</code></pre>

이제는 반대로 이미 포맷된 것에서 읽어 오는 경우도 있습니다.

<pre><code class="line-numbers">{{ some_variable | from_json }}
{{ some_variable | from_yaml }}
</code></pre>

<code>예시</code>

<pre><code class="line-numbers">tasks:
  - shell: cat /some/path/to/file.json
    register: result

  - set_fact: myvar="{{ result.stdout | from_json }}"
</code></pre>

<ul>
<li>어떤 변수가 정의되어야만 하도록 강제함</li>
</ul>

어떤 변수가 정의되어 있지 않다면 ansible의 ansible.cfg에 정의되어 있는 디폴트 행동을 따르게 되어 있는데 이를 끌 수 있습니다.다음은 그 기능이 꺼지고 꼭 해당 변수가 존재하는지 체크하도록 하는 것입니다.

<pre><code class="line-numbers">{{ variable | mandatory }}
</code></pre>

만약 해당 변수가 정의되어 있지 않다면 템플릿이 동작하면서 오류가 발생합니다.

<ul>
<li>정의 되지 않은 변수의 디폴트 값 정의</li>
</ul>

Jinja2 는 <code>default</code> 필터를 제공하는데 해당 변수가 정의되지 않을 경우 디폴트 값을 갖게 됩니다.

<pre><code class="line-numbers">{{ some_variable | default(5) }}
</code></pre>

<ul>
<li>정의되지 않은 변수와 패러미터의 생략</li>
</ul>

버전 1.8 부터 <code>omit</code>이라는 특별 변수를 사용하여 변수나 모듈 패러미터를 생략하기위한 디폴트 필터를 사용할 수 있습니다.

<pre><code class="line-numbers">- name: touch files with an optional mode
  file: dest={{item.path}} state=touch mode={{item.mode|default(omit)}}
  with_items:
    - path: /tmp/foo
    - path: /tmp/bar
    - path: /tmp/baz
      mode: "0444"
</code></pre>

파일경로 <code>path</code>가 3개 있는데 앞에 2개는 시스템에서 제공하는 umask에 따라 touch 되고 마지막 파일경로 <code>/tmp/baz</code> 는 시스템 디폴트 umask와 상관없이 0444 로 설정됩니다.

<h2>2. 데이터  필터</h2>

<ul>
<li>List 필터</li>
</ul>

버전 1.8 이후.

<pre><code class="line-numbers">{{ list1 | min }}
{{ [3, 4, 2] | max }}
</code></pre>

<ul>
<li>집합(SET) 필터</li>
</ul>

버전 1.4 이후.

<pre><code class="line-numbers">#중복 제외
{{ list1 | unique }}    

#합집합
{{ list1 | union(list2) }}

#교집합
{{ list1 | intersect(list2) }}

#차집합
{{ list1 | difference(list2) }}

#합집합 - 교집합
{{ list1 | symmetric_difference(list2) }}
</code></pre>

<ul>
<li>랜덤 필터</li>
</ul>

버전 1.6 이후.

<pre><code class="line-numbers">#임의항목 추출
{{ ['a','b','c']|random }} => 'c'

#0-100 사이의 숫자중 10단위 숫자
{{ 100 |random(step=10) }}  => 70

#10씩 증가하는 숫자 구하기
{{ 100 |random(1, 10) }}    => 31
{{ 100 |random(start=1, step=10) }}    => 51

#셔플 필터
{{ ['a','b','c']|shuffle }} => ['c','a','b']
{{ ['a','b','c']|shuffle }} => ['b','c','a']
</code></pre>

<ul>
<li>Math 필터</li>
</ul>

버전 1.9 이후.

<pre><code class="line-numbers">#로그값 구하기
{{ myvar | log }}

#제곱값 구하기
{{ myvar | pow(2) }}
{{ myvar | pow(5) }}

#제곱근 구하기
{{ myvar | root }}
{{ myvar | root(5) }}
</code></pre>

<ul>
<li>IP 주소 필터</li>
</ul>

버전 1.9 이후.

<pre><code class="line-numbers">{{ myvar | ipaddr }}

#ip 주소를 버전 4,6으로 지정할 때
{{ myvar | ipv4 }}
{{ myvar | ipv6 }}
{{ '192.0.2.1/24' | ipaddr('address') }}
</code></pre>

더 자세한 ipaddr 기능은 <a href="http://docs.ansible.com/ansible/playbooks_filters_ipaddr.html" target="_blank" rel="noopener">Jinja2 ipaddr() 필터</a>를 참조하십시오.

<ul>
<li>유용한 필터</li>
</ul>

<pre><code class="line-numbers">#쉘에서 따옴표 추가
- shell: echo {{ string_value | quote }}

#조건식
{{ (name == "John") | ternary('Mr','Ms') }}

#하나의 문자열로 만들기
{{ list | join(" ") }}

#파일의 경로명 `/etc/asdf/foo.txt`에서 파일명 `foo.txt` 만 추출하려면
{{ path | basename }}

#파일 경로에서 디렉토리만 구하기
{{ path | dirname }}

#링크의 실제 경로
{{ path | realpath }}

#주어진 경로의 상대 경로
{{ path | relpath('/etc') }}

#확장자 분리
# with path == 'nginx.conf' the return would be ('nginx', '.conf')
{{ path | splitext }}

#인코딩 문자열 구하기
{{ encoded | b64decode }}
{{ decoded | b64encode }}

#정규 표현식
# convert "ansible" to "able"
{{ 'ansible' | regex_replace('^a.*i(.*)$', 'a\\1') }}

# convert "foobar" to "bar"
{{ 'foobar' | regex_replace('^f.*o(.*)$', '\\1') }}

# convert "localhost:80" to "localhost, 80" using named groups
{{ 'localhost:80' | regex_replace('^(?P<host>.+):(?P<port>\\d+)$', '\\g<host>, \\g<port>') }}
</code></pre>

<h2>3. Jinja2 테스트 관련 필터</h2>

Jinja2의 테스트는 템플릿을 돌려 True 또는 False 결과를 리턴하는가를 보고 판단합니다. Jinja2의 <a href="http://jinja.pocoo.org/docs/templates/#builtin-tests" target="_blank" rel="noopener">내장 테스트</a> 문서를 참조합니다. 테스트 하는 것은 필터를 이용하는 것과 동일하지만 C(<code>map()</code>) 또는 C(<code>select()</code>) 와 같이 목록에서 항목을 선택하는 것과 같은 목록 처리 필터에도 사용될 수 있습니다.

필터와 마찬가지로 테스트도 로컬 데이터를 테스트하는 Ansible 컨트롤러에서 수행되며, 원격 대상 태스크에서 수행되지는 않습니다.

<h3>3-1. 문자열 테스트</h3>

<pre><code class="line-numbers">vars:
  url: "http://example.com/users/foo/resources/bar"

tasks:
    - shell: "msg='matched pattern 1'"
      when: url | match("http://example.com/users/.*/resources/.*")

    - debug: "msg='matched pattern 2'"
      when: url | search("/users/.*/resources/.*")

    - debug: "msg='matched pattern 3'"
      when: url | search("/users/")
</code></pre>

<code>match</code>는 전체 문자열에 대한 매치를 하는 반면 <code>search</code>는 부분 매치를 합니다.

<h3>3-2. 그룹 포함 테스트</h3>

어떤 그룹이 다른 그룹의 서브셑 또는 수퍼셑 인가를 체크하기 위한 <code>issubset</code>, <code>issuperset</code> 필터가 있습니다.

<pre><code class="line-numbers">vars:
    a: [1,2,3,4,5]
    b: [2,3]
tasks:
    - debug: msg="A includes B"
      when: a|issuperset(b)

    - debug: msg="B is included in A"
      when: b|issubset(a)
</code></pre>

<h3>3-3. 경로 테스트</h3>

<pre><code class="line-numbers">- debug: msg="path is a directory"
  when: mypath|isdir

- debug: msg="path is a file"
  when: mypath|is_file

- debug: msg="path is a symlink"
  when: mypath|is_link

- debug: msg="path already exists"
  when: mypath|exists

- debug: msg="path is {{ (mypath|is_abs)|ternary('absolute','relative')}}"

- debug: msg="path is the same file as path2"
  when: mypath|samefile(path2)

- debug: msg="path is a mount"
  when: mypath|ismount
</code></pre>

<h3>3-4. 태스트 결과 테스트</h3>

<pre><code class="line-numbers">tasks:

  - shell: /usr/bin/foo
    register: result
    ignore_errors: True

  - debug: msg="it failed"
    when: result|failed

  # in most cases you'll want a handler, but if you want to do something right now, this is nice
  - debug: msg="it changed"
    when: result|changed

  - debug: msg="it succeeded in Ansible >= 2.1"
    when: result|succeeded

  - debug: msg="it succeeded"
    when: result|success

  - debug: msg="it was skipped"
    when: result|skipped
</code></pre>

<h2>4. 마치며</h2>

이번시간에는 앤서블의 Jinja2 필터 사용법에 대해서 알아봤습니다. 대부분의 <code>playbook</code> 예시에서 <code>Jinja2</code> 필터는 상당히 많이 사용되고 있습니다. 기존에 개발자가 코딩으로 만들던 부분을 내장함수를 통해서 손쉽게 데이터를 변환하고 조작할 수 있기에 유용합니다.

다음 이시간에는 <code>조건식/반복문</code> 에 대해서 정리해보도록 하겠습니다.

<a href="http://blog.wonizz.com" title="워니즈 블로그">워니즈 블로그</a>
<a href="http://github.com/wonizz" title="워니즈 깃헙" target="_blank" rel="noopener">워니즈 깃헙</a>
<h2 class="wp-block-heading">함께 보면 좋은 글</h2>
<ul class="wp-block-list"><li><a href="https://blog.wonizz.com/2019/07/31/docker-dockerfile/">[Docker] Dockerfile 의 이해</a></li><li><a href="https://blog.wonizz.com/2019/07/29/docker-volume/">[Docker] Volume 의 관리</a></li><li><a href="https://blog.wonizz.com/2019/08/13/docker-compose/">[Docker] Compose 구성과 사용법</a></li><li><a href="https://blog.wonizz.com/2019/08/08/ansible-role-include/">[Ansible] 플레이북 Role 과 Include</a></li></ul>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/09/ansible-jinja2/">[Ansible] 앤서블 Jinja2 필터 사용법</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/08/09/ansible-jinja2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">727</post-id>	</item>
		<item>
		<title>[Ansible] 플레이북 Role 과 Include</title>
		<link>https://blog.wonizz.com/2019/08/08/ansible-role-include/</link>
					<comments>https://blog.wonizz.com/2019/08/08/ansible-role-include/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Thu, 08 Aug 2019 05:49:51 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[도커]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=723</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈입니다. 이번시간에는 Ansible 의 플레북에 대한 이야기를 해보려고 합니다. 필자가 속한 프로젝트에서는 Ansible을 주로 다수의 서버의 configuration 을 수정할 때 사용하고 있습니다. 즉, 1개의 master 파일을 수정하고 각 서버의 경로에 해당 파일로 copy 해주는 단순한 구조입니다. 필자가 있는 프로젝트에서는 다음과 같이 사용합니다 . nginx conf 파일 변경 nginx map 파일 변경 nginx&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/08/ansible-role-include/">[Ansible] 플레이북 Role 과 Include</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
안녕하세요? 정리하는 개발자 워니즈입니다. 이번시간에는 <code>Ansible</code> 의 플레북에 대한 이야기를 해보려고 합니다. 필자가 속한 프로젝트에서는 Ansible을 주로 다수의 서버의 configuration 을 수정할 때 사용하고 있습니다. 즉, 1개의 master 파일을 수정하고 각 서버의 경로에 해당 파일로 copy 해주는 단순한 구조입니다.

<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/08/ANSIBLE_playbook.png?w=1200&#038;ssl=1" alt="ansible playbook" />

필자가 있는 프로젝트에서는 다음과 같이 사용합니다 .

<ul>
<li>nginx conf 파일 변경</li>
<li>nginx map 파일 변경</li>
<li>nginx location 파일 변경</li>
</ul>

다음시간에 <code>nginx</code> conf 구조에 대해서 설명을 하겠지만, 우선 ansible의 가장 효과적인 부분이 다수의 host에서 작업이 가능한 것입니다.

플레이북을 매우 큰 하나의 파일로 작성하는 것도 가능하지만 (초기에 플레이북을 배우면서는 이렇게 하기도 합니다) 점차 플레이북을 재사용하거나 계층적으로 관리할 필요도 생깁니다.

<h2>1. Ansible include</h2>

만약 플레이북의 플레이에 있는 일련의 태스크를 재사용한다고 가정해봅니다. <strong><em>include</em></strong> 를 이용하여 이 작업을 하면 됩니다. 가져온 태스크 목록은 특정 역할(role)을 수행하기에 알맞습니다. 다시한번 강조하면 플레이북은 관리 대상 시스템 그룹에 다양한 역할을 매핑하는 작업입니다.

<pre><code class="line-numbers">---
# possibly saved as tasks/foo.yml

- name: placeholder foo
  command: /bin/foo

- name: placeholder bar
  command: /bin/bar
</code></pre>

<pre><code class="line-numbers">tasks:

  - include: tasks/foo.yml
</code></pre>

분명 위와 아래는 확연히 달라집니다. 같은 내용이더라도, 파일을 <code>include</code>하는 구조가 훨씬 간단해 보입니다.

include 할 때 변수도 포함해서 가져올 수 있습니다. (<em>parameterized include</em> 라고 합니다)

<pre><code class="line-numbers">tasks:
  - include: wordpress.yml wp_user=timmy
  - include: wordpress.yml wp_user=alice
  - include: wordpress.yml wp_user=bob
</code></pre>

버전 1.0 상위부터는 아래와 같이 key, value pair로도 지정이 가능합니다.

<pre><code class="line-numbers">tasks:

  - include: wordpress.yml
    vars:
        wp_user: timmy
        ssh_keys:
          - keys/one.txt
          - keys/two.txt
</code></pre>

<strong><em>include</em></strong>에 작접 패러미터를 전달하던 아니면 <code>vars</code>를 이용하던 상관없습니다.
include 되는 파일에서는

<pre><code class="line-numbers">{{ wp_user }}
</code></pre>

여러개의 하위 플레이북도 <code>include</code> 가 가능합니다.

<pre><code class="line-numbers">- name: this is a play at the top level of a file
  hosts: all
  remote_user: root

  tasks:

  - name: say hi
    tags: foo
    shell: echo "hi..."

- include: load_balancers.yml
- include: webservers.yml
- include: dbservers.yml
</code></pre>

<h2>2. Ansible Role</h2>

버전 1.2 이후

태스크와 핸들러에 관하여 알았으므로 이제는 플레이북을 어떻게 잘 구성하는가를 알아낼 차례입니다. Role을 이용 하면 됩니다. Role은 파일 구조에 따라 vars_files, tasks 와 핸들러 등을 자동으로 로딩하는 것입니다.

처음에 필자는 <code>Role</code>이라는 것 자체가 계정과 역할 이런것일줄 알았는데, 말그대로 어떤 업무 수행단위를 하는지를 Component화 해서 재사용할 수 있도록 하는것으로 보면 될 것 같습니다.

다음과 같은 프로젝트 구조가 되어 있다고 합시다.

<pre><code class="line-numbers">site.yml
webservers.yml
fooservers.yml
roles/
   common/
     files/
     templates/
     tasks/
     handlers/
     vars/
     defaults/
     meta/
   webservers/
     files/
     templates/
     tasks/
     handlers/
     vars/
     defaults/
     meta/
</code></pre>

플레이북에는 다음과 같이 사용합니다.

<pre><code class="line-numbers">---
- hosts: webservers
  roles:
     - common
     - webservers
</code></pre>

다음과 같이 role <code>x</code> 에 대하여 작업이 진행됩니다.

<ul>
<li>만약 <strong>roles/x/tasks/main.yml</strong> 이 존재하면, 그곳에 있는 태스크 들이 플레이에 추가됩니다</li>
<li>만약 <strong>roles/x/handlers/main.yml</strong> 이 존재하면, 그곳에 있는 핸들러 들이 플레이에 추가됩니다</li>
<li>만약 <strong>roles/x/vars/main.yml</strong> 이 존재하면, 그곳에 있는 변수 들이 플레이에 추가됩니다</li>
<li>만약 <strong>roles/x/defaults/main.yml</strong> 이 존재하면, 그곳에 있는 변수 들이 플레이에 추가됩니다</li>
<li>만약 <strong>roles/x/meta/main.yml</strong> 이 존재하면, 그곳에 있는 role 의존성이 role 목록에 추가됩니다 (role 의존성은 아래에 따로 설명합니다)</li>
<li>Role에 있는 다른 어떤 copy, script, template 또는 include task 들은 <strong>role/x/{files,templates,tasks}/</strong> 에 있는 것을 참조합니다.</li>
</ul>

버전 1.4 이후에는 role을 찾기위한 <code>roles_path</code> 설정 변수를 사용할 수 있습니다.

만약 해당 파일이 존재하지 않으면 해당 내용은 무시됩니다. 예를 들어 role을 위한 <strong>vars/</strong> 하위 디렉터리는 없을 수도 있습니다.

<ul>
<li>파라미터 방식</li>
</ul>

<pre><code class="line-numbers">---
- hosts: webservers
  roles:
    - common
    - { role: foo_app_instance, dir: '/opt/a',  app_port: 5000 }
    - { role: foo_app_instance, dir: '/opt/b',  app_port: 5001 }
</code></pre>

<ul>
<li>조건부 방식</li>
</ul>

<pre><code class="line-numbers">---
- hosts: webservers
  roles:
    - { role: some_role, when: "ansible_os_family == 'RedHat'" }
</code></pre>

<ul>
<li>태그방식</li>
</ul>

<pre><code class="line-numbers">---
- hosts: webservers
  roles:
    - { role: foo, tags: ["bar", "baz"] }
</code></pre>

role의 태스크에 있는 이런 tag는 role 안에 단순 정의된 tag를 우선합니다. 만약 만약 특정 role에 있는 여러 task를 부분적으로 사용할 필요가 생긴다면 해당 role을 더 작은 단위로 나눌 필요가 있습니다.

<ul>
<li>순서 지정</li>
</ul>

<pre><code class="line-numbers">---

- hosts: webservers

  pre_tasks:
    - shell: echo 'hello'

  roles:
    - { role: some_role }

  tasks:
    - shell: echo 'still busy'

  post_tasks:
    - shell: echo 'goodbye'
</code></pre>

<h2>3. Ansible Role 예제 분석</h2>

<code>ansible galaxy</code>라는 것을 알게 되어, 처음으로 <code>docker</code> 설치를 한번 해보기 위해서 예제를 다운받았습니다.

<ol>
<li>https://galaxy.ansible.com/geerlingguy/docker 접속</li>
<li>ansible 이 설치된 서버에서 다음을 실행</li>
</ol>

<pre><code class="line-numbers">$ cd /etc/ansible/
$ ansible-galaxy install geerlingguy.docker
</code></pre>

<ol start="3">
<li>roles 폴더 확인</li>
</ol>

<pre><code class="line-numbers">$ cd /etc/ansible/roles
</code></pre>

<pre><code class="line-numbers">defaults/main.yml
handlers/main.yml
LICENSE
meta/main.yml
molecule
README.md
tasks/main.yml
     /docker-1809-shim.yml
     /docker-compose.yml
     /docker-users.yml
     /setup-Debian.yml
     /setup-RedHat.yml
templates/override.conf.j2
</code></pre>

<ol start="4">
<li>실행</li>
</ol>

/etc/ansible 경로에 playbook_docker_test.yml 파일을 생성한뒤, playbook을 실행합니다.

<pre><code class="line-numbers">ansible-playbook playbook_docker_test.yml
</code></pre>

<pre><code class="line-numbers">- hosts: test
  roles:
    - geerlingguy.docker
</code></pre>

<ol start="5">
<li>실행결과 해석</li>
</ol>

<pre><code class="line-numbers">PLAY [test] ************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************************************************************************************************
ok: [https_ids_a01]

TASK [geerlingguy.docker : include_tasks] *****************************************************************************************************************************************************************************************
included: /etc/ansible/roles/geerlingguy.docker/tasks/setup-RedHat.yml for https_ids_a01

TASK [geerlingguy.docker : Ensure old versions of Docker are not installed.] ******************************************************************************************************************************************************
ok: [https_ids_a01]

TASK [geerlingguy.docker : Add Docker GPG key.] ***********************************************************************************************************************************************************************************
ok: [https_ids_a01]

TASK [geerlingguy.docker : Add Docker repository.] ********************************************************************************************************************************************************************************
ok: [https_ids_a01]

TASK [geerlingguy.docker : Configure Docker Edge repo.] ***************************************************************************************************************************************************************************
 [WARNING]: The value 0 (type int) in a string field was converted to u'0' (type string). If this does not look like what you expect, quote the entire value to ensure it does not change.

ok: [https_ids_a01]

TASK [geerlingguy.docker : Configure Docker Test repo.] ***************************************************************************************************************************************************************************
ok: [https_ids_a01]

TASK [geerlingguy.docker : include_tasks] *****************************************************************************************************************************************************************************************
skipping: [https_ids_a01]

TASK [geerlingguy.docker : install the container-selinux rpm from a remote repo] **************************************************************************************************************************************************
ok: [https_ids_a01]

TASK [geerlingguy.docker : Install Docker.] ***************************************************************************************************************************************************************************************
changed: [https_ids_a01]

TASK [geerlingguy.docker : Ensure containerd service dir exists.] **************************************************************************************************************************************************************************
ok: [https_ids_a01]

TASK [geerlingguy.docker : Add shim to ensure Docker can start in all environments.] *******************************************************************************************************************************************************
ok: [https_ids_a01]

TASK [geerlingguy.docker : Reload systemd daemon if template is changed.] ******************************************************************************************************************************************************************
skipping: [https_ids_a01]

TASK [geerlingguy.docker : Ensure Docker is started and enabled at boot.] ******************************************************************************************************************************************************************
changed: [https_ids_a01]

RUNNING HANDLER [geerlingguy.docker : restart docker] **************************************************************************************************************************************************************************************
changed: [https_ids_a01]

TASK [geerlingguy.docker : include_tasks] **************************************************************************************************************************************************************************************************
included: /etc/ansible/roles/geerlingguy.docker/tasks/docker-compose.yml for https_ids_a01

TASK [geerlingguy.docker : Check current docker-compose version.] **************************************************************************************************************************************************************************
ok: [https_ids_a01]

TASK [geerlingguy.docker : Delete existing docker-compose version if it's different.] ******************************************************************************************************************************************************
skipping: [https_ids_a01]

TASK [geerlingguy.docker : Install Docker Compose (if configured).] ************************************************************************************************************************************************************************
ok: [https_ids_a01]

TASK [geerlingguy.docker : include_tasks] **************************************************************************************************************************************************************************************************
[DEPRECATION WARNING]: evaluating [] as a bare variable, this behaviour will go away and you might need to add |bool to the expression in the future. Also see CONDITIONAL_BARE_VARS configuration toggle.. This feature will be removed in
 version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
skipping: [https_ids_a01]

PLAY RECAP *********************************************************************************************************************************************************************************************************************************
https_ids_a01              : ok=16   changed=3    unreachable=0    failed=0    skipped=4    rescued=0    ignored=0   
</code></pre>

제일 먼저, 위의 플레이북 실행 결과를 보면, <code>task/main.yml</code>이 실행 됩니다.

<ul>
<li>setup-RedHat.yml

<ul>
<li>도커 설치</li>
</ul></li>
<li>docker-1809-shim.yml

<ul>
<li>도커 정상시작 체크</li>
<li>도커 방화벽 충돌체크</li>
</ul></li>
<li>docker-compose.yml</li>
<li>docker-users.yml</li>
</ul>

Task의 구조는 위와 같고, 각 yml 파일들이 <code>include</code>되면서 수행이 됩니다.

<h2>4. 필자 Ansible 사용예시</h2>

포스트 서두에 말씀드렸듯이, 필자가 사용하는 방법은 nginx configuration 파일들에 대해서 변경해주고 재시작해주는 방식으로 사용하고 있습니다. 여기서 변경할때는 <code>copy</code>를 하게 되는데 nginx의 멱등성에 의거하여 변경점이 없으면, 업데이트를 안하게 됩니다.

<ol>
<li>playbook_nginx_conf.yml</li>
</ol>

<pre><code class="line-numbers">- hosts: "{{ server }}"
  remote_user: idsuser  
  tasks:
  - name: Change Nginx Config file
    become: yes
    become_method: sudo
    template:
      src: /etc/ansible/config/{{server}}/nginx.conf
      dest: /etc/nginx/nginx.conf

  - name: Validate Config file
    become: yes
    become_method: sudo
    command: "nginx -t"
    register: shell_result

  - debug:
      var: shell_result.stderr_lines
</code></pre>

따로 <code>role</code>관리를 안하고 상위에서 보듯이 하나의 playbook으로 작성했습니다.

<ul>
<li>config 파일 변경</li>
<li>config 파일 이상유무 테스트</li>
</ul>

<ol start="2">
<li>playbook_nginx_restart.yml</li>
</ol>

<pre><code class="line-numbers">- hosts: idsqa_a01
  remote_user: idsuser
  tasks:
  - name: Syntax Test  Nginx.conf
    become: yes
    become_method: sudo
    command: "nginx -t"
    register: shell_result

  - debug:
      var: shell_result.stderr_lines

  - name: Restart Nginx
    become: yes
    become_method: sudo
    service: name=nginx state=restarted
    when: '"nginx: configuration file /etc/nginx/nginx.conf test is successful" in shell_result.stderr_lines'

  - name: Check Nginx Status
    become: yes
    become_method: sudo
    shell: service nginx status
    args:
      warn: false
    register: service_status

  - debug:
      var: service_status.stdout_lines

  - name: Check Process Nginx
    become: yes
    become_method: sudo
    shell: 'ps -ef | grep nginx'
    register: process_result

  - debug:
      var: process_result.stdout_lines

</code></pre>

<ul>
<li>config 파일 이상유무 테스트</li>
<li>nginx 재시작</li>
<li>nginx status 체크</li>
<li>nginx process 체크</li>
</ul>

두 개의 파일로 분할해 두었는데, <code>role</code> 로 <code>task</code>를 쪼개고 하나의 job으로 만드는 것도 좋을 것 같습니다.

<h2>5. 마치며..</h2>

오늘은 ansible의 <code>role</code>과 <code>include</code>에 대해서 알아봤습니다. ansible을 필자도 사용은 하지만, 아주 기초적인 수준으로 사용하고 있었다라는 것을 느꼈습니다. 이번기회에 <code>role</code>관리를 좀더 잘해보고, 특히 <code>ansible-galaxy</code>를 통해서 수준높은 <code>role</code> 관리에 대해서 학습을 좀 더 해보도록 하겠습니다.

다음 시간에는 ansible <code>jinja2</code> 에 대해서 알아보는 시간을 갖도록 하겠습니다.

<a href="http://blog.wonizz.com" title="워니즈 블로그">워니즈 블로그</a>
<a href="http://github.com/wonizz" title="워니즈 깃헙" target="_blank" rel="noopener">워니즈 깃헙</a>
<h2 class="wp-block-heading">함께 보면 좋은 글</h2>
<ul class="wp-block-list"><li><a href="https://blog.wonizz.com/2019/07/31/docker-dockerfile/">[Docker] Dockerfile 의 이해</a></li><li><a href="https://blog.wonizz.com/2019/07/29/docker-volume/">[Docker] Volume 의 관리</a></li><li><a href="https://blog.wonizz.com/2019/08/13/docker-compose/">[Docker] Compose 구성과 사용법</a></li><li><a href="https://blog.wonizz.com/2019/07/27/docker-network/">[Docker] 네트워크의 이해</a></li></ul>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/08/ansible-role-include/">[Ansible] 플레이북 Role 과 Include</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/08/08/ansible-role-include/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">723</post-id>	</item>
		<item>
		<title>[리눅스 명령어] sed 사용법</title>
		<link>https://blog.wonizz.com/2019/08/07/linux-sed/</link>
					<comments>https://blog.wonizz.com/2019/08/07/linux-sed/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Wed, 07 Aug 2019 07:26:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=714</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다. 이번시간에는 지난번 awk 에 이어서 리눅스 명령어 2편 sed에 대해서 정리해 보도록 하겠습니다. awk 명령어(1/3) sed 명령어(2/3) cut 명령어(2/3) 1. sed 란? sed는 Stream EDitor의 약자로 매우 컴팩트한 명령 체계를 이용하여 텍스트를 파싱하고 변형하는 (고대의) 텍스트 편집 도구이다. sed는 그 전신이 되는 ed의 스크립팅 체계를 기반으로 하고 있다. vim과 같이&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/07/linux-sed/">[리눅스 명령어] sed 사용법</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다. 이번시간에는 지난번 awk 에 이어서 리눅스 명령어 2편 <code>sed</code>에 대해서 정리해 보도록 하겠습니다.</p>
<p><a href="https://blog.wonizz.com/2019/08/06/linux-awk/" title="awk 명령어(1/3)">awk 명령어(1/3)</a><br />
<a href="https://blog.wonizz.com/2019/08/06/linux-sed/" title="sed 명령어(2/3)">sed 명령어(2/3)</a><br />
cut 명령어(2/3)</p>
<h2>1. sed 란?</h2>
<p>sed는 Stream EDitor의 약자로 매우 컴팩트한 명령 체계를 이용하여 텍스트를 파싱하고 변형하는 (고대의) 텍스트 편집 도구이다. sed는 그 전신이 되는 ed의 스크립팅 체계를 기반으로 하고 있다. vim과 같이 편집될 텍스트를 화면상에 보면서 내용을 작성/수정하는 개념의 텍스트 편집기가 개발되기 이전의 텍스트 편집기이다.</p>
<p><img data-recalc-dims="1" height="600" width="1200" decoding="async" src="https://i0.wp.com/linuxconcept.com/wp-content/uploads/2019/02/sed-1280x640.png?resize=1200%2C600&#038;ssl=1" alt="리눅스 명령어 sed 사용법" /></p>
<p>일반적으로 에디터로 텍스트를 조작하려 할 때, 사람들이 주로 하는 방식은 다음과 같을 것입니다.</p>
<ol>
<li>에디터를 켭니다.</li>
<li>편집할 텍스트파일을 다.</li>
<li>편집할 위치로 커서를 이동합니다.</li>
<li>내용을 수정합니다.</li>
<li>파일을 저장합니다.</li>
<li>에디터를 닫습니다.</li>
</ol>
<p>그런데, 위의 과정을 SED로 진행하기 위해서는 다음이 필요합니다.</p>
<ul>
<li>텍스트 내용을 완벽히 알고 있어야한다.</li>
<li>어느라인 혹은 어떤 내용을 수정할지 알고있어야 한다.</li>
<li>스크립트를 활용해서 해당 라인을 수정한다.</li>
</ul>
<h2>2. sed 명령어 사용법</h2>
<ul>
<li>기본</li>
</ul>
<pre><code class="line-numbers">$ sed [옵션] 스크립트 입력파일1 [입력파일2 ... ]
</code></pre>
<ul>
<li>옵션</li>
</ul>
<table>
<thead>
<tr>
<th>옵션/스위치</th>
<th>별칭</th>
<th>기능</th>
</tr>
</thead>
<tbody>
<tr>
<td>-n</td>
<td>&#8211;quiet, &#8211;silent</td>
<td>읽어들인 라인을 암시적으로 자동출력하는 것을 중단한다.</td>
</tr>
<tr>
<td>-e</td>
<td>&#8211;expression=script</td>
<td>실행될 명령에 스크립트를 추가한다</td>
</tr>
<tr>
<td>-f script_file</td>
<td>&#8211;file=script_file</td>
<td>스크립트 파일의 내용을 가져와서 추가로 실행한다.</td>
</tr>
<tr>
<td>&#8211;follow-symlinks</td>
<td></td>
<td>제자리 처리시에 심볼릭 링크를 따르도록 한다. 하드링크는 깨진다.</td>
</tr>
<tr>
<td>-i[SUFFIX]</td>
<td>&#8211;in-place[=SUFFIX]</td>
<td>파일을 제자리 처리한다. (즉 변경된 내용을 파일에 적용한다.)</td>
</tr>
<tr>
<td>-c</td>
<td></td>
<td>제자리 처리시에 사본을 이용한다.</td>
</tr>
<tr>
<td>-l N</td>
<td>&#8211;copy</td>
<td>한줄의 길이를 정의한다.</td>
</tr>
<tr>
<td></td>
<td>&#8211;line-length=N</td>
<td>모든 GNU확장을 제외한다.&#8211;line-length=N</td>
</tr>
<tr>
<td>-r</td>
<td>&#8211;posix</td>
<td>확장된 정규식 패턴을 사용한다.</td>
</tr>
<tr>
<td>-s</td>
<td>&#8211;regexp-extended</td>
<td>파일을 하나의 긴 스트림이 아닌 분리된 데이터들로 처리한다.</td>
</tr>
<tr>
<td>-u</td>
<td>&#8211;separate</td>
<td>입력으로부터 최소한의 내용만 읽고 더 자주 플러시한다.</td>
</tr>
<tr>
<td></td>
<td>도움말을 표시한다.</td>
<td></td>
</tr>
</tbody>
</table>
<p>필자가 상위의 내용을 정리해두었지만, 사실 필자도 주로 사용하는 옵션은 <code>-n</code>,<code>-e</code> 정도 입니다. <code>sed</code>를 주로 치환용도로 많이 사용하다보니, 활용법을 잘 몰랐습니다.</p>
<p>이번 포스팅에 대한 정리를 <code>sed</code>에 대해서 심도 깊게 할 수 도있지만, 주로 활용법위주로 많이 해두어야 개발자 분들이 많이 가져다가 사용할 것 같습니다. 그래서 예시로 정리하겠습니다.</p>
<ul>
<li>f 옵션도 자주 사용하는 것 같아서 정리합니다.</li>
</ul>
<p>sed명령어의 -f(file)선택자를 사용하면 명령어를 일일이 키보드에서 입력하지 않고 하나의 파일에 기억시켜 놓고 사용할 수도 있다.</p>
<pre><code class="line-numbers"> # sed -f command.file in.file
</code></pre>
<p>여러 개의 명령어를 연속적으로 자주 사용할 때 이 명령어 파일이 유용하게 사용된다.<br />
예를 들어 다음과 같은 복수 개의 명령어가 파일에 기억되어 있는 경우는</p>
<pre><code class="line-numbers"> # vi command.file
   s/hello/goodbye
   s/good/bad
</code></pre>
<p>다음과 같은 명령어를 입력하면 다음과 같이 출력된다.</p>
<pre><code class="line-numbers"> # echo "1234hello5678" | sed -f command.file
   => 1234badbye5678
</code></pre>
<ol>
<li>치환</li>
</ol>
<pre><code class="line-numbers">sed 's/addrass/address/' list.txt : addrass를 address로 바꾼다. 단, 원본파일을 바꾸지 않고 표준출력만 한다.
sed 's/\t/\ /' list.txt : 탭문자를 엔터로 변환

</code></pre>
<ol start="2">
<li>삭제</li>
</ol>
<pre><code class="line-numbers">sed '/TD/d' 1.html : TD 문자가 포함된 줄을 삭제하여 출력한다.
sed '/Src/!d' 1.html : Src 문자가 있는 줄만 지우지 않는다.
sed '1,2d' 1.html : 처음 1줄, 2줄을 지운다.
sed '/^$/d 1.html : 공백라인을 삭제하는 명령이다. (★★★)
</code></pre>
<h2>3. sed 예시</h2>
<ul>
<li>치환 예시</li>
</ul>
<pre><code class="line-numbers">#특정 문자열 바꾸기
sed 's/hello/goodbye/' tempfile.txt

#특정 문자열이 포함된 행에서 특정 문자만 제거 하기
sed 's/hello//g' tempfile.txt

#파일의 일부만 편집해야 할 경우 라인의 범위를 지정하여 사용가능
sed '3,7s/hello//g' tempfile.txt

#라인 번호 대신 문맥을 범위로 지정한 경우
sed '/hello/,/goodbye/s/bad/good' tmepfile.txt
sed '/hello/,/goodbye/s/bad/good/g' tmepfile.txt

#특정라인의 문자 치환
sed -n '5s/hello/####/g' tmepfile.txt
</code></pre>
<ul>
<li>삭제 예시</li>
</ul>
<pre><code class="line-numbers">#특정 문자열 포함한 라인 제거
sed 's/hello/d' tempfile.txt

#3번째 라인을 삭제 
sed '3d' tempfile.txt

#princess 또는 Princess를 포함하고 있는 라인들을 삭제함
sed '/[hH]ello/d' tempfile.txt

#라인 1부터 hello를 포함하고 있는 첫번째 라인까지 모든 라인을 삭제함
sed '1,/hello/d' tempfile.txt

#tempfile.xtxt 안의 데이터로부터 처음 세 개의 문자열을 삭제함
sed 's/...//' tempfile.txt

#tempfile.xtxt 안의 데이터로부터 마지막 세 개의 문자열을 삭제함
sed 's/...$//' tempfile.txt

#모든 공백라인 제거
sed '^$/d' tempfile.txt

#여기서부터는 실제 cli창에 테스트 해보세요!
#각 라인의 첫번째 공백에서 마지막까지 삭제함
who | sed 's/ .*$//'

#각 라인의 처음부터 맨 마지막 공백까지 삭제
who | sed 's/^.*$//'

#각 라인의 처음부터 : 문자가 있는 곳(:문자포함)까지 삭제
who | sed 's/^.*://'
</code></pre>
<ul>
<li>입/출력 예시</li>
</ul>
<pre><code class="line-numbers">#각 라인마다 뒤에 Hello World! 문자를 입력
sed 'a\\Hello World\!' tempfile.txt

#3번째라인 뒤에 Good Morning 문자 삽입
sed '3a\\Good Morning' tempfile.txt

#각 라인마다 공백라인 추가
sed 'a\\' tempfile.txt

#hello 문자가 들어있는 line만 프린트
sed -n '/hello/p' tempfile.txt

#hello 문자가 들어있는 라인 중복 출력?
sed '/hello/p' tempfile.txt
</code></pre>
<ul>
<li>필자가 사용했던 예시</li>
</ul>
<pre><code class="line-numbers">#리눅스 서버에서 password 관련 셋팅 치환
sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/" /etc/ssh/sshd_config
sed -i "s/#system/#team-system/g" *.location  

#자빅스 처음 셋팅할때 php 파일 설정들 치환
sudo sed -i 's/^max_execution_time.*/max_execution_time=600/' /etc/php.ini
sudo sed -i 's/^max_input_time.*/max_input_time=600/' /etc/php.ini
sudo sed -i 's/^memory_limit.*/memory_limit=256M/' /etc/php.ini
sudo sed -i 's/^post_max_size.*/post_max_size=32M/' /etc/php.ini
sudo sed -i 's/^upload_max_filesize.*/upload_max_filesize=16M/' /etc/php.ini
sudo sed -i "s/^\;date.timezone.*/date.timezone=\'Asia\/Tokyo\'/" /etc/php.ini

#현재 폴더에서 특정문자열 치환
find ./ -type f -name "*" -exec sed -i 's/io.honeymon/kakaopay.com/g' {} \;

#로그파일에서 특정 문자열을 찾은뒤, 공백라인 제거
zcat replication.log.2018-11-21.gz | grep '/sk/feature' |grep qa_pub_a01 | awk '{print $9}' | sed '/^$/d'
</code></pre>
<h2>4. 마치며</h2>
<p>sed는 흔히 s///를 써서 특정한 파일이나 명령의 출력에서 특정 문자열을 치환하는 명령어로만 알았습니다. 하지만, sed 역시 편집기로 분류됩니다. 리눅스에서 아시다시피, 편집기하면 제일먼저 떠오르는것은 <code>vim</code> 입니다. 하지만, 그 이전 시대에는 <code>sed</code>를 많이 활용했던것 같습니다. 확실히 <code>sed</code>는 치환,삭제 등 라인의 변경에 대해서 유용하게 사용할 수 있을 것 같습니다.</p>
<p>-i 옵션을 사용하지 않는 이상 원본 파일에 되쓰는 일은 없습니다.<br />
 sed는 기본적으로 처리된 결과를 출력하는 일을 수행하며, 그 결과를 파일로 만들기 위해서는 주로 리다이렉션을 사용한다.</p>
<p>다음시간에는 <code>cut</code> 에 대해서 알아보는 시간을 갖도록 하겠습니다.</p>
<p><a href="http://blog.wonizz.com" title="워니즈 블로그">워니즈 블로그</a><br />
<a href="http://github.com/wonizz" title="워니즈 깃헙" target="_blank" rel="noopener">워니즈 깃헙</a></p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/07/linux-sed/">[리눅스 명령어] sed 사용법</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/08/07/linux-sed/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">714</post-id>	</item>
		<item>
		<title>[Docker] Dockerfile 의 이해</title>
		<link>https://blog.wonizz.com/2019/07/31/docker-dockerfile/</link>
					<comments>https://blog.wonizz.com/2019/07/31/docker-dockerfile/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Wed, 31 Jul 2019 04:50:08 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[도커]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=644</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다. 이번 시간에는 도커 파일 에 대해서 알아보도록 하겠습니다. 지난번 docker 이야기는 설치하고 기본적인 사용법과 볼륨에 대해서 알아봤습니다. 이제는 이미지가 어떻게 빌드가 되고, 이미지로부터 container를 어떻게 생성하는지 알아보는 시간을 갖도록 하겠습니다. 1. 도커파일 이란? Dockerfile 도커 파일은 이미지를 생성하기 위한 스크립트이며, 도커 파일 빌드를 하면 완성된 이미지를 얻게 됩니다. 필자는 도커파일은&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/07/31/docker-dockerfile/">[Docker] Dockerfile 의 이해</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
안녕하세요? 정리하는 개발자 워니즈 입니다. 이번 시간에는 도커 파일 에 대해서 알아보도록 하겠습니다. 지난번 docker 이야기는 설치하고 기본적인 사용법과 볼륨에 대해서 알아봤습니다. 이제는 이미지가 어떻게 빌드가 되고, 이미지로부터 container를 어떻게 생성하는지 알아보는 시간을 갖도록 하겠습니다.

<h2> </h2>

<h2>1. 도커파일 이란?</h2>

<ul>
<li>Dockerfile</li>
</ul>

<blockquote>
  도커 파일은 이미지를 생성하기 위한 스크립트이며, 도커 파일 빌드를 하면 완성된 이미지를 얻게 됩니다. 
  필자는 도커파일은 마치 이미지를 생성하기 위한 명세서라고 생각합니다. 제 3자가 도커파일만 보고 이 이미지가 어떤 역할을 하는지 어떤식으로 구성이 되어있는지 확인할 수 있습니다.
</blockquote>

<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.octo.com/wp-content/uploads/2014/01/docker-stages.png?w=1200&#038;ssl=1" alt="Docker 엔지니어링" title="RubberDuck" />
<a href="https://github.com/search?utf8=%E2%9C%93&#038;q=dockerfile%EF%BF%BC" title="도커파일 예시" target="_blank" rel="noopener">도커파일 예시</a>

위에서 보시는것처럼 Docker에서 이미지를 생성하기 위한 방법은 3가지가 있습니다.

<ol>
<li>도커파일</li>
<li>컨테이너 커밋</li>
<li>이미지 태그</li>
</ol>

이중 가장 일반적이고 CI/CD로 활용되어지는 방법은 Dockerfile로 빌드해 이미지를 생성하는 방법입니다.
필자가 Devops 과제에서 선보인 내용에서 spring-bood app을 그라들 빌드해서 jar파일을 가져오고 Dockerfile에 명세를 젂어서 이미지로 추출하는 내용을 넣었습니다.

Dockerfile은 사용자가 이미지를 생성하기위해 순차적으로 작성한 명령어로 된 Text문서이며, <em>docker build</em> 명령어로 Dockerfile과 Context를 통해 이미지를 생성합니다.

<pre><code class="line-numbers"># mkdir /dockerfile
# cd dockerfile
# gedit dockerfile
</code></pre>

<ul>
<li>이미지 빌드</li>
</ul>

<pre><code class="line-numbers"># docker build --tag myubuntu:1.0 .
# docker images
</code></pre>

-t, &#8211;tag : 저장소 이름, 이미지 이름, 태그를 설정합니다. &lt;저장소 이름>/&lt;이미지 이름>:&lt;태그> 형식

<code>.</code> : Build Context

<ul>
<li>컨테이너 실행</li>
</ul>

<pre><code class="line-numbers">docker run -it --rm --name myubuntu myubuntu:1.0 /bin/bash
</code></pre>

&#8211;name : 컨테이너 명 지정

-d : 컨테이너를 백그라운드로 실행

-it : 터미널모드로 실행

-p 호스트와 컨테이너 포트를 연결해 노출

&#8211;rm 실행 후 컨테이너 자동삭제

<h2>2. 명령어</h2>

<ul>
<li>FROM</li>
</ul>

<pre>FROM <image> [AS <name>]
FROM <image>[:<tag>] [AS <name>]
FROM <image>[@<digest>] [AS <name>]
</pre>

<code>도커파일</code>

<pre><code class="line-numbers">FROM ubuntu:18.04

# Container에서 실행할 명령
CMD ["/bin/echo", "hello docker"]
</code></pre>

<code>이미지 빌드</code>

<pre><code class="line-numbers"># docker build -t localhost:5000/myununtu:v2 .
# docker run localhost:5000/myununtu:v2
</code></pre>

<ul>
<li>LABEL</li>
</ul>

<code>LABEL</code> instruction는 Label로 지정한 문자열을 이미지에 메타데이터로 추가합니다.

<code>LABEL</code> 은 key-value 쌍으로 작성하며 , space를 포함시키기 위해서는 따옴표(<code>""</code>)를 이어쓰기를 위해서는 백슬래쉬(<code>\</code>)를 사용하면 됩니다.

<pre>LABEL <key>=<value> <key>=<value> <key>=<value> ...
</pre>

도커파일

<pre><code class="line-numbers">FROM ubuntu:18.04

LABEL multi.label1="value1" multi.label2="value2" other="value3"
LABEL multi.label1="value1" \
      multi.label2="value2" \
      other="value3"

# Container에서 실행할 명령
CMD ["/bin/echo", "hello docker"]
</code></pre>

이미지 빌드

<pre><code class="line-numbers"># docker build -t localhost:5000/myununtu:v2 .
# docker run -it localhost:5000/myununtu:v2 /bin/bash
</code></pre>

이렇게 추가된 Lavel은 컨테이너 실행시 <code>docker inspect</code> 명령어로 내용을 확인 할 수 있습니다.

다만 주의할 것은  Base 이미지에 포함된 Lavel 값이 상속된다는 점이고, 만약 같은 Lavel값이 존재한다면 가장 최근에 적용된 Lavel값이 우선합니다.

<pre><code class="line-numbers">"Labels": {
    "com.example.vendor": "ACME Incorporated"
    "com.example.label-with-value": "foo",
    "version": "1.0",
    "description": "This text illustrates that label-values can span multiple lines.",
    "multi.label1": "value1",
    "multi.label2": "value2",
    "other": "value3"
},
</code></pre>

<ul>
<li>RUN

<code>RUN</code> instruction는 Base Image위에 필요한 패키지를 설치할 때 사용하는 명령어입니다.. <code>Run</code>명령어가 수행된 이후에는 새로운 Layer가 Base이미지 위에 생성됩니다.</p></li>
</ul>

shell form : command 로 입력받은 명령어는 쉘에서 수행되며 디폴트로 리눅스에서는 /bin/sh -c 이 윈도우에서는 cmd /S /C 가 사용됩니다.

<pre><code class="line-numbers">RUN <command>
</code></pre>

<pre>RUN ["executable", "param1", "param2"]
</pre>

<code>도커파일</code>

<code>RUN</code> instruction은 현재생성된 이미지의 위의 새로운 레이어를 생성하여 그 안에서 명령어를 수행하고 그 결과를 레이어에 commit합니다. 따라서 \ (backslash)를 사용하여 RUN을 수행한 것과 여러개의 RUN을 수행한 것은 결과는 동일하나 생성된 레이어의 갯수가 차이가 있게 됩니다.

<pre><code class="line-numbers">FROM ubuntu:14.04
RUN apt-get update
RUN apt-get install -y package-a
RUN apt-get install -y package-b
RUN apt-get install -y package-c
</code></pre>

<pre><code class="line-numbers">FROM ubuntu:14.04
RUN apt-get update && apt-get install -y \
        package-a \
        package-b \
        package-c
</code></pre>

<ul>
<li>CMD

<code>CMD</code> instruction은 Docker Container가 시작할때 실행 할 커맨드를 지정하는 지시자이며 아래와 같은 특징과 기능을 제공합니다.

</li>
</ul>

<ol>
<li><strong>CMD의 주용도는 컨테이너를 실행할 때 사용할 default 명령어를 설정</strong>하는 것입니다.<code>docker run</code> 실행 시 실행할 커맨드를 주지 않으면 CMD로 지정한 default 명령이 실행됩니다.</li>
<li><code>ENTRYPOINT</code>의 파라미터를 설정할 수도 있습니다.</li>
<li><code>RUN</code> instruction 과 기능은 비슷하지만 차이점은 <code>CMD</code>는 docker image를 빌드할때 실행되는 것이 아니라 docker container가 시작될때 실행됩니다. 주로 docker image로 빌드된 application을 실행할때 사용됩니다.</li>
</ol>

<code>CMD</code> instruction 는 아래와 같이 3가지 포맷을 지원합니다.

<ol>
<li><code>CMD ["executable","param1","param2"]</code> (<em>exec</em> form, this is the preferred form)</li>
<li><code>CMD ["param1","param2"]</code> (as <em>default parameters to ENTRYPOINT</em>)</li>
<li><code>CMD command param1 param2</code> (<em>shell</em> form)</li>
</ol>

<code>도커 파일</code>

<pre><code class="line-numbers">FROM ubuntu
...
CMD ["apache2","-DFOREGROUN"]
</code></pre>

<pre><code class="line-numbers">FROM ubuntu
...
CMD ["python"]
</code></pre>

<pre><code class="line-numbers">FROM ubuntu
CMD echo "This is a test."
</code></pre>

<pre><code class="line-numbers">FROM ubuntu
CMD ["/usr/bin/wc","--help"]
</code></pre>

<ul>
<li>ENTRYPOINT</li>
</ul>

Docker image가 실행될때 기본 command를 지정합니다. <code>CMD</code>와 비슷하지만 <code>CMD</code>는 override 가 가능하지만 <code>ENTRYPOINT</code> 는 override 할 수 없습니다. 대신에 <code>docker run</code> 커맨드로 추가하는 커맨드들은 <code>ENTRYPOINT</code> instruction에 지정된 커맨드에 옵션으로 추가됩니다.

<code>ENTRYPOINT</code> instruction 는 아래와 같이 2가지 포맷을 지원합니다.

<ul>
<li><code>ENTRYPOINT ["executable", "param1", "param2"]</code> (<em>exec</em> form, preferred)</li>
<li><code>ENTRYPOINT command param1 param2</code> (<em>shell</em> form)</li>
</ul>

<code>도커파일</code>

<pre><code class="line-numbers">FROM ubuntu
ENTRYPOINT ["/bin/echo", "Hello world"]
</code></pre>

<code>ENTRYPOINT & CMD instruction 예제</code>

<pre><code class="line-numbers">FROM centos
ENTRYPOINT ["/bin/echo", "Hello world"]
CMD ["world"]
</code></pre>

<pre><code class="line-numbers"># gedit dockerfile

# docker build --tag localhost:5000/hello:1.1 .

컨테이너를 실행에 어떤 내용이 출력되는지 확인해봅시다.
# docker run -it localhost:5000/hello:1.1
# docker run -it localhost:5000/hello:1.1 cmdtest
</code></pre>

<ul>
<li>EXPOSE</li>
</ul>

<code>EXPOSE</code> 명령은 Container가 Runtime시 수신대기할 포트를 지정하는 명령어입니다. 포트번호 및 TCP 또는 UDP를 지정할 수 있으며 프로토콜이 지정되지 않을 경우 기본값은 TCP입니다.

주의해야할 점은 EXPOSE 명령어 자체가 실제로 포트를 열지 않는다는 점입니다. EXPOSE 명령은 이미지를 만드는 사람과 이미지를 사용하는 사람이 포트 및 프로토콜 규약을 명시해놓은 문서기능을 하는 것이고 실제 Container의 포트는 docker run -p 옵션으로 Container를 실행하는 시점에 -p 옵션으로 지정된 포트가 개방됩니다.

<pre>EXPOSE <port> [<port>/<protocol>...]
</pre>

<code>도커파일</code>

<pre><code class="line-numbers">EXPOSE 80/udp
EXPOSE 80/tcp
</code></pre>

<ul>
<li>ENV</li>
</ul>

<code>ENV</code>명령어는 환경변수 <code><key></code> 를 <code><value></code>로 설정하는 지시자입니다. 쉽게 일반 프로그래밍에서 변수를 지정하는 것과 동일하다고 생각하면 됩니다.

<code>ENV</code>를 사용하여 셋팅된 환경변수는 Container Runtime시에도 셋팅된 변수가 유지됩니다.

<pre>ENV <key> <value>
ENV <key>=<value> ...
</pre>

<code>도커파일</code>

<pre><code class="line-numbers">FROM busybox
ENV FOO /bar
WORKDIR ${FOO}   # WORKDIR /bar
COPY . /quux # COPY all to /quux
</code></pre>

<ul>
<li>COPY</li>
</ul>

호스트의 Context 내의 파일 또는 디렉터리들을 Container의 파일시스템으로 복사하는 명령어입니다. 또한 <code>--chown</code> 옵션으로 파일 및 디렉터리에 대한 유저와 그룹을 지정할 수 있습니다

<ol>
<li>COPY [&#8211;chown=<user>:<group>] <src>&#8230; <dest>`</li>
<li><code>COPY [--chown=<user>:<group>] ["<src>",... "<dest>"]</code> (this form is required for paths containing whitespace)</li>
</ol>

<code>도커 파일</code>

<pre><code class="line-numbers">COPY . /bar/             # adds all files and directories
COPY test.jar /bin/test/ # adds a test.jar file
COPY hom* /mydir/        # adds all files starting with "hom"
COPY hom?.txt /mydir/    # ? is replaced with any single character, e.g., "home.txt"
COPY --chown=55:mygroup files* /somedir/
COPY --chown=bin files* /somedir/
COPY --chown=1 files* /somedir/
COPY --chown=10:11 files* /somedir/
</code></pre>

<code>COPY --chown</code>에 의해 주어진 유저명과 그룹명으로 지정되지 않은 모든 파일 및 디렉터리들은 Container안에서 UID, GID 0번으로 생성됩니다.

<ul>
<li>ADD</li>
</ul>

ADD는 Syntax 및 기능면에서 COPY와 유사 URL을 지정해 파일을 복사 할 수 있고 압축파일(tar)을 을 자동으로 풀어서 복사한다는 점에서 차이가 있습니다.

<ol>
<li>ADD [&#8211;chown=<user>:<group>] <src>&#8230; <dest>`</li>
<li><code>ADD [--chown=<user>:<group>] ["<src>",... "<dest>"]</code>(this form is required for paths containing whitespace)</li>
</ol>

<code>도커 파일</code>

<pre><code class="line-numbers">ADD http://example.com/big.tar.xz /usr/src/things/
RUN tar -xJf /usr/src/things/big.tar.xz -C /usr/src/things
RUN make -C /usr/src/things all
</code></pre>

<ul>
<li>USER</li>
</ul>

Docker로 Container를 수행할때 Container 실행 유저는 Docker의 기본설정으로 root계정입니다.

<pre>root@ubuntu:/# docker run ubuntu whoami
root
</pre>

USER 명령어는 이러한 Container안에서 명령을 실행 할 유저명과 유저그룹을 설정하는 명령어이며, Dockerfile 안에서 USER명령어를 셋팅한 이후의 RUN, CMD, ENTRYPONT 명령어에 적용됩니다.

<pre><code class="line-numbers">USER <user>[:<group>] or
USER <UID>[:<GID>]
</code></pre>

<code>도커 파일</code>

<pre><code class="line-numbers"># 시스템 그룹 및 유저로 postgres를 추가한다. 
RUN groupadd -r postgres && useradd --no-log-init -r -g postgres postgres

# Run the rest of the commands as the `postgres` user
USER postgres
</code></pre>

<ul>
<li>WORKDIR</li>
</ul>

WORKDIR<code>명령어는</code>WORKDIR<code>명령어에 뒤따르는</code>WORKDIR<code>,</code>RUN<code>,</code>CMD<code>,</code>ENTRYPOINT<code>,</code>COPY<code>,</code>ADD`명령어의 작업디렉터리를 지정하는 명령어입니다. 쉽게 말해 리눅스 cd명령어와 비슷하다고 생각하면 됩니다.

<pre><code class="line-numbers">WORKDIR /path/to/workdir
</code></pre>

<code>도커 파일</code>

<pre><code class="line-numbers">WORKDIR /a   # 작업디렉터리를 /a로 이동합니다
WORKDIR b    # /a에서 하위의 b디렉터리로 이동합니다.
WORKDIR c    # /a/b에서 하위의 c디렉터리로 이동합니다.
RUN pwd      # RUN명령어가 실행되는 디렉터리는 WORKDIR로 이동한 /a/b/c가 됩니다.
</code></pre>

주의할 점은, Linux cd명령어와는 다르게 만약 <code>WORKDIR</code>로 지정한 디렉터리가 존재하지 않을 경우, 그 디렉터리를 Container 안에 생성한다는 점에서 다릅니다.

아래와 같이 <code>ENV</code>로 지정한 환경변수와 함께 쓰일 수 있다는 점도 참고바랍니다.

<pre><code class="line-numbers">ENV DIRPATH /path
ENV DIRNAME dname
WORKDIR $DIRPATH/$DIRNAME
RUN pwd                   # 출력결과 /path/dname
</code></pre>

<ul>
<li>VOLUME</li>
</ul>

<code>VOLUME</code> 은 컨테이너에서 생성된 데이터를 영구보존하고자 할때 사용되는 명령어로 컨테이너가 실행될때 Volume 명령어로 선언된 Container 안의 지점을 Container 밖의 특정지점과 자동으로 마운트되어 컨테이너가 실행됩니다.

이때 Host에 생성되는 경로는 /var/lib/docker/volumes/{volume_name}이고, volume_name은 Docker에서 생성하는 해쉬값으로 생성이됩니다.

<pre><code class="line-numbers">VOLUME ["/data"]
</code></pre>

<code>도커 파일</code>

<pre><code class="line-numbers">FROM ubuntu
RUN mkdir /myvol
RUN echo "hello world" > /myvol/greeting
VOLUME /myvol
CMD ["/bin/bash"]
</code></pre>

생성한 이미지를 실행하여 볼륨을 조회해 보면 신규로 볼륨을 조회해보면 신규로 한개가 생긴것을 확인할 수 있고 생성된 볼륨디렉터리로 들어가면 dockerfile에서 생성한 file을 확인 할 수 있습니다.

<pre><code class="line-numbers">root@ubuntu:/dockerfile# docker volume ls
DRIVER              VOLUME NAME
local               fbfdbb0b0236c712bd8f2034aa699e0a23a6449915fad90cc0ae07e7f570b0a9
root@ubuntu:/dockerfile# cd /var/lib/docker/volumes && ls
fbfdbb0b0236c712bd8f2034aa699e0a23a6449915fad90cc0ae07e7f570b0a9  metadata.db

root@ubuntu:/var/lib/docker/volumes# cd fbfdbb0b0236c712bd8f2034aa699e0a23a6449915fad90cc0ae07e7f570b0a9
root@ubuntu:/var/lib/docker/volumes/fbfdbb0b0236c712bd8f2034aa699e0a23a6449915fad90cc0ae07e7f570b0a9# ls
_data
root@ubuntu:/var/lib/docker/volumes/fbfdbb0b0236c712bd8f2034aa699e0a23a6449915fad90cc0ae07e7f570b0a9# cd _data/
root@ubuntu:/var/lib/docker/volumes/fbfdbb0b0236c712bd8f2034aa699e0a23a6449915fad90cc0ae07e7f570b0a9/_data# ls
greeting
</code></pre>

이렇게 dockerfile에서만 Volume을 명시해두고 docker실행시 디폴트로 마운트하게되면, docker에서 자동으로 volume을 생성해주지만, Hash값으로 생성하기 때문에 관리하기가 쉽지 않습니다.

따라서 앞서 배운 내용을 바탕으로 Volume을 사전에 미리 생성해두고, 실행시 dockerfile 안에 명시된 경로로 마운트해보도록하겠습니다.

<pre><code class="line-numbers">root@ubuntu:/# docker volume create volume2
volume2
root@ubuntu:/# docker volume ls
DRIVER              VOLUME NAME
local               fbfdbb0b0236c712bd8f2034aa699e0a23a6449915fad90cc0ae07e7f570b0a9
local               volume2
</code></pre>

Volume을 컨테이너 기동시 마운트하면 이 디렉터리가 컨테이너의 지정된 디렉터리로 마운트됩니다.

<pre><code class="line-numbers"># docker run -it --name volumetest --mount source=volume2,target=/myvol localhost/volumetest:v1 /bin/bash
root@a52260c673a7:/# cd /myvol && ls
greeting
root@a52260c673a7:/myvol# exit

root@ubuntu:/# cd /var/lib/docker/volumes/volume2/_data/ && ls
greeting
</code></pre>

명령어를 정리하면서 다음과 같은 명령어는 혼동해서 사용하면 안될 것 같았습니다.

<ol>
<li>COPY vs ADD</li>
<li>RUN vs CMD</li>
<li>ENTRYPOINT &#038; CMD</li>
</ol>

<h2>3. 실습 예제</h2>

<ol>
<li>아래 주석의 내용을 dockerfile로 완성해보세요

시작하기 전 index.html 파일은 아래와 같이 만드시면 됩니다.

<pre><code class="line-numbers"># echo hello world! > index.html

# gedit dockerfile
</code></pre>

<pre><code class="line-numbers"># Base 이미지는 nginx 1.14.1 버전으로 한다.
# author는 guest이다
# 환경변수로 아래 내용을 셋팅한다.
# HTTP_PROXY "http://70.10.15.10:8080"
# HTTPS_PROXY "http://70.10.15.10:8080"
# FTP_PROXY "http://70.10.15.10:8080"
# http_proxy "http://70.10.15.10:8080"
# https_proxy "http://70.10.15.10:8080"
# ftp_proxy "http://70.10.15.10:8080"
# 패키지를 update한다.
# apt-get update
# index.html 파일을 /usr/share/nginx/html 디렉터리로 복사한다.

# 컨테이너에 tcp 80 포트을 개방한다.

# 컨테이너 시작시 필수로 아래 명령어를 수행한다.
# ["nginx"]

# 컨테이너 시작후 nginx의 실행 옵션으로 ["-g", "daemon off;"]를 수행한다.
</code></pre></li>
<li>완성된 docker file을 build 해보세요

</li>
<li>

빌드된 이미지 실행해 Host의 8080으로 포트를 매핑하고 터미널로 연결해보세요

</li>
<li>

연결된 터미널에서 curl localhost:8080  명령으로 nginx가 정상적으로 동작하는지 확인해보세요

</li>
</ol>

<pre><code class="line-numbers"># Base 이미지는 nginx 1.14.1 버전으로 한다.
FROM nginx:1.14.1


# 환경변수로 아래 내용을 셋팅한다.
ENV HTTP_PROXY "http://70.10.15.10:8080"
ENV HTTPS_PROXY "http://70.10.15.10:8080"
ENV FTP_PROXY "http://70.10.15.10:8080"
ENV http_proxy "http://70.10.15.10:8080"
ENV https_proxy "http://70.10.15.10:8080"
ENV ftp_proxy "http://70.10.15.10:8080"

# 패키지를 update한다.
RUN apt-get update

# index.html 파일을 /usr/share/nginx/html 디렉터리로 복사한다.
COPY index.html /usr/share/nginx/html/

# 컨테이너에 tcp 80 포트을 개방한다.
EXPOSE 80/tcp

# 컨테이너 시작시 필수로 아래 명령어를 수행한다.
# ["nginx"]
ENTRYPOINT ["nginx"]

# 컨테이너 시작후 nginx의 실행 옵션으로 ["-g", "daemon off;"]를 수행한다.
CMD ["-g", "daemon off;"]
</code></pre>

<ol>
<li>완성된 docker file을 build 해보세요

docker build -t localhost:5000/mynginx:1.0 .</p></li>
<li>빌드된 이미지 실행해 Host의 8080으로 포트를 매핑하고 터미널로 연결해보세요

docker run -d -p 8080:80 localhost:5000/mynginx:1.0</p></li>
<li>연결된 터미널에서 curl localhost:8080명령으로 nginx가 정상적으로 동작하는지 확인해보세요

curl localhost:8080</p></li>
</ol>

<h2>4. BuildKit, 이제는 기본 빌더입니다</h2>

<p>이 글을 처음 쓸 때는 다루지 않았는데요, 도커 공식 문서(docs.docker.com/build/buildkit)를 다시 확인해보니 지금은 BuildKit 이 Docker Desktop 과 Docker Engine 사용자 모두에게 기본 빌더로 적용돼 있다고 명시돼 있습니다. 위에서 쓴 <code>docker build</code> 명령은 전부 그대로 쓸 수 있지만, 뒤에서 실제로 돌아가는 엔진이 예전 레거시 빌더에서 BuildKit 으로 바뀌었다는 점은 알아두면 좋습니다.</p>

<p>공식 문서가 밝힌 BuildKit 의 개선점은 이렇습니다.</p>

<ul>
<li>쓰이지 않는 빌드 스테이지는 실행을 건너뜁니다</li>
<li>서로 의존하지 않는 빌드 스테이지는 병렬로 처리합니다</li>
<li>컨텍스트에서 바뀐 파일만 증분으로 전송합니다</li>
</ul>

<p>직접 확인: 터미널에서 <code>docker buildx version</code> 을 실행하면 BuildKit 기반 빌더가 설치돼 있는지 바로 볼 수 있습니다. 반대로 예전 방식 그대로 빌드하고 싶다면 <code>DOCKER_BUILDKIT=0 docker build .</code> 처럼 환경변수로 끌 수 있는데, 레거시 빌더는 언젠가 없어질 예정이라 굳이 끌 이유는 없습니다.</p>

<p>BuildKit 이 기본이 되면서 같이 널리 쓰이게 된 것이 멀티스테이지 빌드입니다. 위에서 다룬 <code>FROM</code> 명령어를 한 Dockerfile 안에서 여러 번 써서 빌드용 이미지와 실행용 이미지를 분리하는 방식인데요, 빌드 도구가 잔뜩 들어간 무거운 이미지를 그대로 배포하지 않고 결과물만 가벼운 런타임 이미지로 옮겨 담을 수 있습니다.</p>

<pre><code class="line-numbers">FROM golang:1.22 AS builder
WORKDIR /src
COPY . .
RUN go build -o app .

FROM alpine:3.19
COPY --from=builder /src/app /app
ENTRYPOINT ["/app"]
</code></pre>

<p>위 예제에서 최종 이미지에는 golang 빌드 환경이 전혀 남지 않고, 컴파일된 바이너리 <code>app</code> 과 alpine 베이스만 남습니다. 이미지 용량을 크게 줄일 수 있어서 실무에서는 거의 기본값처럼 쓰이고 있습니다.</p>

<h2>5. 마치며</h2>

이번 시간에는 도커파일이 어떤것이고 각 명령어에 대해서 알아봤으며, 최종적으로 실습예제를 통해서 사용법을 개괄적으로 보았습니다. 확실히 도커파일이 있으면 명시적으로 어떤 이미지인지 명세를 알 수 있으며, 도커파일만 있다면 언제 어디서든지 도커 이미지를 생성해 낼 수 있기에 굉장히 편리합니다.

다음시간에는 도커의 CI/CD에 대해서 살펴보겠습니다.

<a href="http://blog.wonizz.com" title="워니즈 블로그">워니즈 블로그</a>
<a href="http://github.com/wonizz" title="워니즈 깃헙" target="_blank" rel="noopener">워니즈 깃헙</a>
<h2 class="wp-block-heading">함께 보면 좋은 글</h2>
<ul class="wp-block-list"><li><a href="https://blog.wonizz.com/2019/07/29/docker-volume/">[Docker] Volume 의 관리</a></li><li><a href="https://blog.wonizz.com/2019/07/27/docker-network/">[Docker] 네트워크의 이해</a></li><li><a href="https://blog.wonizz.com/2019/08/08/ansible-role-include/">[Ansible] 플레이북 Role 과 Include</a></li><li><a href="https://blog.wonizz.com/2019/08/13/docker-compose/">[Docker] Compose 구성과 사용법</a></li></ul>


<p>AI 도구로 초안을 만들고 직접 실행·검증한 내용입니다.</p><p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/07/31/docker-dockerfile/">[Docker] Dockerfile 의 이해</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/07/31/docker-dockerfile/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">644</post-id>	</item>
		<item>
		<title>[Docker] Volume 의 관리</title>
		<link>https://blog.wonizz.com/2019/07/29/docker-volume/</link>
					<comments>https://blog.wonizz.com/2019/07/29/docker-volume/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Mon, 29 Jul 2019 04:12:06 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[도커]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=636</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>Docker 에서 데이터를 관리하는 방법에 관한 내용으로, Docker로 컨테이너를 실행 후 컨테이너 안에서 파일을 생성하면 Docker의 기본설정으로 모든 파일들을 컨테이너 안의 writable layer에 저장됩니다. 하지만 이러한 매커니즘은 실제 시스템 운영환경에서는 많은 문제를 가지고 있습니다. 예를 들어 컨테이너에서 생성한 파일들이 컨테이너가 재시작되더라도 유지되어야 한다면, 아래의 내용을 생각해 보아야 합니다. 컨테이너가 중지되면 데이터는 컨테이너와 함께 제거되고, 유지되지&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/07/29/docker-volume/">[Docker] Volume 의 관리</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
Docker 에서 데이터를 관리하는 방법에 관한 내용으로, Docker로 컨테이너를 실행 후 컨테이너 안에서 파일을 생성하면 Docker의 기본설정으로 모든 파일들을 컨테이너 안의 writable layer에 저장됩니다.

하지만 이러한 매커니즘은 실제 시스템 운영환경에서는 많은 문제를 가지고 있습니다. 예를 들어 컨테이너에서 생성한 파일들이 컨테이너가 재시작되더라도 유지되어야 한다면, 아래의 내용을 생각해 보아야 합니다.

<ul>
<li>컨테이너가 중지되면 데이터는 컨테이너와 함께 제거되고, 유지되지 않습니다.</li>
<li>다른 프로세스 또는 애플리케이션에서 컨테이너 안의 데이터를 사용하기 위해 컨테이너 밖으로 데이터를 가져오는 것은 번거롭거나 어려운 작업이 될 수 있습니다.</li>
<li>컨테이너의 writable layer에 데이터를 기록하기 위해서는 파일스시템을 관리 할 <a href="https://docs.docker.com/storage/storagedriver/" target="_blank" rel="noopener">storage driver</a> 가 필요합니다. storage driver는 리눅스의 커널을 이용해서 union filesystem을 제공하기때문에 이러한 추가적인 추상화로 인해 Host 파일시스템에 직접 데이터를 기록하는 것과 비교해보면 성능측면에서 약점으로 작용합니다.</li>
</ul>

Docker에서는 컨테이너가 중지되더라도 데이터를 유지하기 위한 방법으로  Host 머신에 파일을 저장하는 3가지 방법을 제공합니다.

<ul>
<li>Volume</li>
<li>Bind mount</li>
<li>Tmpfs mount (On Linux)</li>
</ul>

<h2>1. Volume 타입의 선택</h2>

위에서 언급한 3가지 유형의 어떤 마운트 방법을 사용하던, 컨테이너에서 보여지는 데이터는 동일하지만, 3가지 유혀의 Mount는 Host의 어떠한 영역에 마운트되느냐에 차이점이 있습니다.

<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/docs.docker.com/storage/images/types-of-mounts.png?w=1200&#038;ssl=1" alt="types of mounts and where they live on the Docker host" />

<ul>
<li>Volumes** : Docker에 의해 관리되는 Host 파일시스템 영역에 데이터를 저장합니다.

(<code>/var/lib/docker/volumes/</code> on Linux).

Docker에 의해 관리되고, Non-Docker process는 이 영역을 수정할 수 없으므로 Volume은 Docker에서 영구데이터를 관리하는 가장 좋은 방법입니다.</p></li>
<li><strong>Bind mounts</strong> : Host 머신의 파일시스템 어디에나 파일을 저장할 수 있는 방법입니다. Docker외의 다른 프로세스에서 데이터의 접근과 수정이 가능합니다.</p></li>
<li><strong>tmpfs mounts</strong> : Host의 메모리에 데이터를 저장하는 방법입니다.</p></li>
</ul>

<h2>2. Volume 타입의 상세</h2>

<ul>
<li>volume</li>
</ul>

Docker에 의해 만들어지고 관리되는 Volume은  <code>docker volume create</code> 명령어로 명시적으로 Volume을 생성할 수 있습니다.

<pre><code class="line-numbers">root@ubuntu:/# docker volume create volume1
volume1

root@ubuntu:/# docker volume ls
DRIVER              VOLUME NAME
local               volume1
</code></pre>

Volume을 생성하면 Docker Host 머신의 Docker에서 관리하는 디렉터리에 저장됩니다.

<pre><code class="line-numbers">root@ubuntu:/# docker volume inspect volume1
[
    {
        "CreatedAt": "2019-02-22T02:25:12+09:00",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/volume1/_data",
        "Name": "volume1",
        "Options": {},
        "Scope": "local"
    }
]

root@ubuntu:/# ls /var/lib/docker/volumes/
metadata.db  volume1
</code></pre>

Volume을 컨테이너 기동시 마운트하면 이 디렉터리가 컨테이너의 지정된 디렉터리로 마운트됩니다.

<pre><code class="line-numbers">root@ubuntu:/# docker run -it --name myubuntu --mount source=volume1,target=/volumedata ubuntu
root@da5fe2af29c5:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var  volumedata
root@da5fe2af29c5:/# cd volumedata/
root@da5fe2af29c5:/volumedata# touch hellovolume
root@da5fe2af29c5:/volumedata# ls
hellovolume
root@da5fe2af29c5:/volumedata# exit
exit

root@ubuntu:/# cd /var/lib/docker/volumes/volume1/_data/
root@ubuntu:/var/lib/docker/volumes/volume1/_data# ls
hellovolume
</code></pre>

Container 정보를 살펴보면 기본설정으로 Volume의 읽기쓰기모드가 RW(읽기쓰기) 인 것을 알 수 있습니다.

<code>--mount</code> 옵션에 <code>readonly</code> 옵션을 주어 읽기쓰기 모드를 변경 할 수 있습니다

<pre><code class="line-numbers">root@ubuntu:/# docker inspect myubuntu
[
    {
        "Id": "f6369bab35f2c89c0e0fed76c024decc4c19707aa833f6407fc0b1f60f42c38c",
        "Created": "2019-02-21T23:40:56.46535649Z",
        "Path": "/bin/bash",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 29553,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2019-02-21T23:40:57.125309312Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
       ...
        "Mounts": [
            {
                "Type": "volume",
                "Name": "volume1",
                "Source": "/var/lib/docker/volumes/volume1/_data",
                "Destination": "/volumedata",
                "Driver": "local",
                "Mode": "z",
                "RW": true,
                "Propagation": ""
            }
        ],

</code></pre>

<pre><code class="line-numbers"># docker run -it --name myubuntu1 --mount source=volume1,target=/volumedata,readonly ubuntu

# docker inspect myubuntu1
[
    {
        "Id": "47e5ba4a6746ab416e2b1985040805cc7574c368989ae9d9dbe6d2186236ba33",
        "Created": "2019-02-21T23:46:07.024314426Z",
        "Path": "/bin/bash",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 29663,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2019-02-21T23:46:07.413027114Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
       ...
        "Mounts": [
            {
                "Type": "volume",
                "Name": "volume1",
                "Source": "/var/lib/docker/volumes/volume1/_data",
                "Destination": "/volumedata",
                "Driver": "local",
                "Mode": "z",
                "RW": false,
                "Propagation": ""
            }
        ],
        ...

root@47e5ba4a6746:/volumedata# touch test
touch: cannot touch 'test': Read-only file system
</code></pre>

Volume은 동시에 여러 컨테이너에 마운트 할 수 있으며, 자동으로 Volume이 제거되지 않습니다.

Volume을 제거하기 위해서는 <code>docker volume rm</code>,  <code>docker volume prune</code>  명령어로 제거 할 수 있습니다.

<pre><code class="line-numbers"># docker volume rm volume1
</code></pre>

사용하지 않은 Volume을 제거하기 <code>docker volume prune</code>  명령어로 정리 할 수 있습니다.

<pre><code class="line-numbers"># docker volume prune
</code></pre>

volume 관련 명령어

<table>
<thead>
<tr>
  <th>Command</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td><a href="https://docs.docker.com/engine/reference/commandline/volume_create/" target="_blank" rel="noopener">docker volume create</a></td>
  <td>Create a volume</td>
</tr>
<tr>
  <td><a href="https://docs.docker.com/engine/reference/commandline/volume_inspect/" target="_blank" rel="noopener">docker volume inspect</a></td>
  <td>Display detailed information on one or more volumes</td>
</tr>
<tr>
  <td><a href="https://docs.docker.com/engine/reference/commandline/volume_ls/" target="_blank" rel="noopener">docker volume ls</a></td>
  <td>List volumes</td>
</tr>
<tr>
  <td><a href="https://docs.docker.com/engine/reference/commandline/volume_prune/" target="_blank" rel="noopener">docker volume prune</a></td>
  <td>Remove all unused local volumes</td>
</tr>
<tr>
  <td><a href="https://docs.docker.com/engine/reference/commandline/volume_rm/" target="_blank" rel="noopener">docker volume rm</a></td>
  <td>Remove one or more volumes</td>
</tr>
</tbody>
</table>

<ul>
<li>Bind mount</li>
</ul>

Bind mount는 Volume에 비해 기능이 제한되어 있습니다. Bind mount를 사용하면 Container를 Host 머신의 특정 파일이나 디렉터리로 마운트합니다. Host의 마운트 경로는 Full Path를 사용하는데, 해당 파일이나 경로가 존재하지 않을 경우 자동생성되어지기때문에 미리 생성되어 있을 필요는 없습니다.

<pre><code class="line-numbers"># docker run -it -v /volume/bindmount:/data/bindmount ubuntu
root@b1f8e57c3314:/data/bindmount# cd /data/bindmount
root@b1f8e57c3314:/data/bindmount# touch testfile
root@b1f8e57c3314:/data/bindmount# ls
testfile
root@b1f8e57c3314:/data/bindmount# exit
root@ubuntu:/# cd /volume/bindmount/
root@ubuntu:/volume/bindmount# ls
testfile
</code></pre>

Bind mount는 Volume에 비해 아래와 같은 불리한 점이 있기 때문에 가능하다면 Volume을 사용하는 것이 권장됩니다.

<ol>
<li>Bind mount는 Host의 디렉터리 구조에 의존적입니다.</li>
<li>Docker에 의해 관리되어지지 않습니다.</li>
<li>Container안의 프로세스가 Host의 파일시스템을 변경할 수 있으므로 보안상 위협이 될 수 있습니다.</li>
</ol>

<ul>
<li>tmpfs mounts</li>
</ul>

<code>tmpfs</code> mount는 디스크에 데이터를 영구적으로 저장하지 않고 Host의 메모리에 저장합니다. 이러한 특징 때문에 tmfs mount Container의 생명주기와 맞춰서 데이터를 보존하고자 할 때 사용되어질 수 있습니다. 예를 들어, 내부적으로 Docker swarm service는 tmpfs mount를 사용하여 컨테이너 안으로 secret을 마운트합니다.

<h2>3. 예제</h2>

docker 데이터 볼륨으로 데이터 공유를 해보겠습니다.

<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/07/DV_exam.jpg?w=1200&#038;ssl=1" alt="Docker Volume 의 관리 설명 이미지 1" />

다음 명령을 실행하여 컨테이너를 생성하고 데이터 볼륨을 설정합니다. 컨테이너의 Bash 셸이 실행되면 /data 디렉터리로 이동한 뒤 world라는 빈 파일을 생성합니다. 그리고 exit를 입력하여 Bash 셸에서 빠져나옵니다.

<pre><code class="line-numbers">$ sudo docker run -i -t --name hello-volume1 -v /root/data:/data ubuntu /bin/bash
root@f7baf3abefee:/# cd /data
root@f7baf3abefee:/data# touch world
root@f7baf3abefee:/data# exit
</code></pre>

데이터 볼륨 옵션은 -v &lt;호스트 디렉터리>:&lt;컨테이너 디렉터리> 형식입니다. 여기서는 호스트의 /root/data 디렉터리를 Docker 컨테이너의 /data 디렉터리에 연결합니다.

/root/data 디렉터리의 파일 목록을 출력합니다.

<pre><code class="line-numbers">$ sudo ls /root/data
world
</code></pre>

앞에서 생성한 world 파일이 보입니다.

이제 두 번째 컨테이너를 생성합니다. 컨테이너의 Bash 셸이 실행되면 /data 디렉터리의 파일 목록을 출력합니다.

<pre><code class="line-numbers">$ sudo docker run -i -t --name hello-volume2 -v /root/data:/data ubuntu /bin/bash
root@af5a7bdb3e5a:/# ls /data
world
</code></pre>

앞에서 생성한 world 파일이 hello-volume2 파일에서도 보입니다. /data 디렉터리에 파일을 생성하면 호스트 및 hello-volume1 컨테이너에서도 사용할 수 있습니다. 이렇게 데이터 볼륨 설정을 통해 컨테이너끼리 데이터를 공유할 수 있습니다.

디렉터리뿐만 아니라 호스트의 파일 하나만 컨테이너에 연결할 수도 있습니다.

<pre><code class="line-numbers">$ sudo docker run -i -t --name hello-volume -v /root/hello.txt:/root/hello.txt \
    ubuntu /bin/bash
</code></pre>

<h2>4. 볼륨 백업과 복원</h2>

지금까지 Volume 을 만들고 마운트하는 방법을 봤는데, 실제 운영에서는 백업하고 복원하는 방법도 같이 알아둬야 합니다. Docker 공식 문서(docs.docker.com)가 안내하는 방식은 백업 전용 컨테이너를 하나 띄워 그 안에서 tar 로 압축하는 것입니다.

먼저 데이터가 들어 있는 볼륨을 가진 컨테이너를 하나 만듭니다.

<pre><code class="line-numbers">$ docker run -v /dbdata --name dbstore ubuntu /bin/bash
</code></pre>

이 컨테이너는 실행만 되고 바로 멈춰도 상관없습니다. 뒤에서 <code>--volumes-from</code> 옵션으로 이 컨테이너가 가진 볼륨만 참조할 것이기 때문입니다.

<pre><code class="line-numbers">$ docker run --rm --volumes-from dbstore -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata
</code></pre>

<code>--volumes-from dbstore</code> 로 dbstore 컨테이너의 볼륨을 그대로 물려받고, 현재 디렉터리를 <code>/backup</code> 으로 마운트한 뒤 그 안의 데이터를 tar 로 압축합니다. 명령이 끝나면 <code>--rm</code> 옵션 때문에 이 컨테이너는 바로 삭제되고, 현재 디렉터리에 <code>backup.tar</code> 파일만 남습니다.

복원은 반대 순서로 하면 됩니다. 새 컨테이너를 하나 만들고,

<pre><code class="line-numbers">$ docker run -v /dbdata --name dbstore2 ubuntu /bin/bash
</code></pre>

그 컨테이너의 볼륨에 백업 파일 내용을 풀어 넣습니다.

<pre><code class="line-numbers">$ docker run --rm --volumes-from dbstore2 -v $(pwd):/backup ubuntu bash -c "cd /dbdata &amp;&amp; tar xvf /backup/backup.tar --strip 1"
</code></pre>

<code>--strip 1</code> 옵션은 tar 안에 저장된 최상위 디렉터리 경로를 한 단계 벗겨내는 역할입니다. 이 과정을 거치면 dbstore 의 <code>/dbdata</code> 에 있던 파일이 dbstore2 의 <code>/dbdata</code> 에서도 그대로 보입니다.

<strong>직접 확인</strong>: 위 네 줄을 로컬 Docker 로 그대로 실행하면, dbstore 컨테이너의 <code>/dbdata</code> 에 파일 하나를 만들어 둔 뒤 dbstore2 에서 <code>docker exec -it dbstore2 ls /dbdata</code> 로 같은 파일이 보이는지 확인할 수 있습니다. 운영 서버를 옮기거나 재설치하기 전에 이 방식으로 볼륨만 따로 복사해 두면, 컨테이너를 전부 새로 띄워도 데이터는 그대로 이어집니다.

<h2>5. 자주 하는 실수</h2>

Volume 을 쓰다 보면 반복되는 실수가 몇 가지 있습니다.

<ul>
<li><strong>docker compose down -v 로 데이터까지 날리는 경우</strong>: <code>docker compose down</code> 에 <code>-v</code> 옵션을 붙이면 compose 파일에 정의된 named volume 과 컨테이너에 붙어 있던 anonymous volume 이 함께 삭제됩니다. 컨테이너만 내리고 데이터는 남기고 싶다면 <code>-v</code> 없이 <code>docker compose down</code> 만 실행해야 합니다.</li>
<li><strong>이름 없는 볼륨(anonymous volume)이 쌓여 디스크를 먹는 경우</strong>: 이름을 지정하지 않고 컨테이너를 반복해서 재생성하면, 그때마다 새 anonymous volume 이 만들어지고 이전 것은 어떤 컨테이너에도 연결되지 않은 채 디스크에 남습니다. <code>docker system df -v</code> 로 볼륨이 차지한 용량을 먼저 확인하고, <code>docker volume prune</code> 으로 어떤 컨테이너도 쓰지 않는 볼륨만 정리합니다. prune 은 사용 중이지 않은 볼륨을 전부 지우므로, 실행 전에 <code>docker volume ls</code> 로 지워도 되는 목록인지 한 번 확인하는 편이 안전합니다.</li>
</ul>

<h2>6. 마치며</h2>

이상으로 docker volume에 대해서 알아봤습니다. 필자 같은 경우는 주로, bind mount방식으로 많이 사용하고 있습니다. 
정확하게 어떠한 방식이 더 좋다라고는 말씀드리기 어렵지만, 각 자의 방식에 맞춰서 유동적으로 사용하시면 될것 같습니다.

다음시간에는 Compose 구성과 사용법에 대해서 알아보겠습니다.

<a href="http://blog.wonizz.com" title="워니즈 블로그">워니즈 블로그</a>
<a href="http://github.com/wonizz" title="워니즈 깃헙" target="_blank" rel="noopener">워니즈 깃헙</a>
<h2 class="wp-block-heading">함께 보면 좋은 글</h2>
<ul class="wp-block-list"><li><a href="https://blog.wonizz.com/2019/07/31/docker-dockerfile/">[Docker] Dockerfile 의 이해</a></li><li><a href="https://blog.wonizz.com/2019/07/27/docker-network/">[Docker] 네트워크의 이해</a></li><li><a href="https://blog.wonizz.com/2019/08/08/ansible-role-include/">[Ansible] 플레이북 Role 과 Include</a></li><li><a href="https://blog.wonizz.com/2019/08/13/docker-compose/">[Docker] Compose 구성과 사용법</a></li></ul>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/07/29/docker-volume/">[Docker] Volume 의 관리</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/07/29/docker-volume/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">636</post-id>	</item>
		<item>
		<title>[Docker] 네트워크의 이해</title>
		<link>https://blog.wonizz.com/2019/07/27/docker-network/</link>
					<comments>https://blog.wonizz.com/2019/07/27/docker-network/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Sat, 27 Jul 2019 12:53:00 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[도커]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=627</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈입니다. 지난 시간에 도커의 설치 및 사용법에 대해서 알아봤는데요. 오늘은 도커의 네트워크가 어떻게 이루어져 있는지를 간단한 구성도와 예제를 통해 알아보려고 합니다.:smile: 1. 네트워크 드라이버 도커의 네트워크 방식은 크게 4가지입니다. 브릿지 네트워크 docker의 기본 network 방식은 bridge 이다. docker daemon을 실행하면 먼저 docker0 라는 bridge가 생성된다. 컨테이너 생성하게 되면, 각 컨테이너 마다 고유한&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/07/27/docker-network/">[Docker] 네트워크의 이해</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
안녕하세요? 정리하는 개발자 워니즈입니다. 지난 시간에 도커의 설치 및 사용법에 대해서 알아봤는데요. 오늘은 도커의 네트워크가 어떻게 이루어져 있는지를 간단한 구성도와 예제를 통해 알아보려고 합니다.:smile:

<h2>1. 네트워크 드라이버</h2>

도커의 네트워크 방식은 크게 4가지입니다.

<ul>
<li>브릿지 네트워크

docker의 기본 network 방식은 bridge 이다.
docker daemon을 실행하면 먼저 docker0 라는 bridge가 생성된다.
컨테이너 생성하게 되면, 각 컨테이너 마다 고유한 network namespace 영역이 하나씩 생성되며,
이때 docker0 bridge에 container의 인터페이스들이 하나씩 binding 되는 구조이다.</li>


<li>호스트 네트워크

host 방식으로 컨테이너를 생성하면, 컨테이너가 독립적인 네트워크 영역을 갖지 않고 host와 네트워크를 함께 사용하게 된다.
(네트워크 외 다른 환경은 기존과 동일하다)
컨테이너 생성시 <code>--network host</code> 옵션을 이용하면 된다.</li>
<li>컨테이너

이 방식으로 생성된 컨테이너는 기존에 존재하는 다른 컨테이너의 network 환경을 공유하게 된다.</li>
<li>none

<code>--network none</code> 옵션으로 컨테이너를 생성하면 격리된 네트워크 영역을 갖긴 하지만, 인터페이스가 없는 상태로 컨테이너를 생성하게 된다.</li>
</ul>

<h2>2. nginx 실행하기</h2>

간단한 예제로 네트워크를 알아보기 위해서 nginx image를 pull받고 실행하여 살펴보도록 하겠습니다.

<pre><code class="line-numbers">docker pull nginx
</code></pre>

Docker Container 구동

<pre><code class="line-numbers">docker run -d --name my-nginx -p 8080:80 nginx
</code></pre>

<ul>
<li>**&#8211;name**: Container 명 지정</li>
<li>**-p**:컨테이너 포트 지정(8080으로 접속시 80으로 포트포워딩)</li>
</ul>

접속 확인

<pre><code class="line-numbers">curl http://127.0.0.1:8080

브라우저에서 http://127.0.0.1:8080
</code></pre>

컨테이너 정보

<pre><code class="line-numbers"># docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
e2a871a929e8        nginx               "nginx -g 'daemon of…"   3 minutes ago       Up 3 minutes        0.0.0.0:8080->80/tcp   my-nginx

# docker container inspect e2a871a929e8
</code></pre>

<h2>3.브릿지 네트워크(Default)</h2>

<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/07/dockerNat.png?w=1200&#038;ssl=1" alt="Dockr bridge network" />

브라우저에서 http://127.0.0.1:8080 입력시 어떤 과정으로 컨테이너 안으로 접속했는지에 대해 알아봅시다.

<ol>
<li>Host에 8080으로 요청이 들어옵니다.</li>
<li>들어온 요청은 Host에 구성된 NAT 테이블을 통해 HostIP:8080 -> ContainerIP:80으로 변환됩니다.</li>
<li>변환된 ContainerIP:80는 Docker0이라는 가상네트워크 인터페이스가 Subnet 172.17.0.1/16으로 구성되어 있으므로  172.17.0.2의 IP로 접근가능하게 됩니다.</li>
</ol>

기동된 Container의 네트워크 정보를 살펴보면 위에서 설명한 내용대로 구성되어 있음을 확인 할 수 있습니다.

<ul>
<li>NAT 정보</li>
</ul>

iptables -t nat -L -n로 출력된 내용중
DNAT       tcp  &#8212;  0.0.0.0/0            0.0.0.0/0            tcp dpt:8080 to:172.17.0.2:80
부분을 확인할 수 있습니다.

<pre><code class="line-numbers"># iptables -t nat -L -n
target     prot opt source               destination         
DOCKER     all  --  0.0.0.0/0            0.0.0.0/0            ADDRTYPE match dst-type LOCAL

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
DOCKER     all  --  0.0.0.0/0           !127.0.0.0/8          ADDRTYPE match dst-type LOCAL

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  172.17.0.0/16        0.0.0.0/0           
MASQUERADE  tcp  --  172.17.0.2           172.17.0.2           tcp dpt:80

Chain DOCKER (2 references)
target     prot opt source               destination         
RETURN     all  --  0.0.0.0/0            0.0.0.0/0           
DNAT       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:8080 to:172.17.0.2:80
</code></pre>

bridge network정보
docker network inspect bridge 명령을 통해 네트워크 정보를 살펴보면
contaner network는 &#8220;Subnet&#8221;: &#8220;172.17.0.1/16&#8221;, &#8220;Gateway&#8221;: &#8220;172.17.0.1&#8221; 으로 구성되며, Gateway 역할을 하는 인터페이스 네트워크는 docker0임을 알수 있습니다.

<pre><code class="line-numbers"># docker network inspect bridge

[
    {
        "Name": "bridge",
        "Id": "f7ab26d71dbd6f557852c7156ae0574bbf62c42f539b50c8ebde0f728a253b6f",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.1/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },
        "Internal": false,
        "Containers": {
            "3386a527aa08b37ea9232cbcace2d2458d49f44bb05a6b775fba7ddd40d8f92c": {
                "Name": "networktest",
                "EndpointID": "647c12443e91faf0fd508b6edfe59c30b642abb60dfab890b4bdccee38750bc1",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "9001"
        },
        "Labels": {}
    }
]
</code></pre>

<h2>4. 마치며</h2>

이상으로 Docker 네트워크에 대해서 알아봤습니다. 위에서 설명한 Docker의 네트워크 구조는 docker가 지원하는 방식 중 bridge 모드에 대한 설명이다. bridge 모드는 docker 네트워크의 default 설정이자 가장 많이 쓰이는 방식이다.
다음시간에는 Docker Volume에 대해서 정리를 해보도록 하겠습니다.

<a href="https://blog.wonizz.com" title="워니즈 블로그">워니즈 블로그</a>
<a href="https://github.com/wonizz" title="워니즈 깃헙" target="_blank" rel="noopener">워니즈 깃헙</a>
<h2 class="wp-block-heading">함께 보면 좋은 글</h2>
<ul class="wp-block-list"><li><a href="https://blog.wonizz.com/2019/07/31/docker-dockerfile/">[Docker] Dockerfile 의 이해</a></li><li><a href="https://blog.wonizz.com/2019/07/29/docker-volume/">[Docker] Volume 의 관리</a></li><li><a href="https://blog.wonizz.com/2019/08/13/docker-compose/">[Docker] Compose 구성과 사용법</a></li><li><a href="https://blog.wonizz.com/2019/08/08/ansible-role-include/">[Ansible] 플레이북 Role 과 Include</a></li></ul>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/07/27/docker-network/">[Docker] 네트워크의 이해</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/07/27/docker-network/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">627</post-id>	</item>
		<item>
		<title>[Rundeck] 런덱 업그레이드</title>
		<link>https://blog.wonizz.com/2019/07/24/rundeck-upgrade-guide/</link>
					<comments>https://blog.wonizz.com/2019/07/24/rundeck-upgrade-guide/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Wed, 24 Jul 2019 06:52:44 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[DevOps]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=586</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다. 지난번에 런덱 설치하기를 알아봤는데요. 이번에는 런덱 업그레이드 절차에 대해서 소개하려합니다. 제가 속한 프로젝트는 런덱 2.11.1 버전을 사용하고 있습니다. 이버전을 최신 버전인 3.024로 업그레이드를 하려고 합니다. 업그레이드 전에 뭐가 바뀌었나 확인해본결과, UI적인 측면이 가장 돋보인다고 나와있습니다. New “Jalapeño Popper” UI The new 3.0 UI is an aesthetic update with an eye&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/07/24/rundeck-upgrade-guide/">[Rundeck] 런덱 업그레이드</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다.<br />
지난번에 <a href="https://blog.wonizz.com/2019/07/23/rundeck-install-guide/" title="런덱 설치하기">런덱 설치하기</a>를 알아봤는데요. 이번에는 런덱 업그레이드 절차에 대해서 소개하려합니다.<br />
제가 속한 프로젝트는 런덱 2.11.1 버전을 사용하고 있습니다. 이버전을 최신 버전인 3.024로 업그레이드를 하려고 합니다.</p>
<p>업그레이드 전에 뭐가 바뀌었나 확인해본결과, UI적인 측면이 가장 돋보인다고 나와있습니다.</p>
<blockquote><p>
  New “Jalapeño Popper” UI<br />
  The new 3.0 UI is an aesthetic update with an eye towards what comes next.
</p></blockquote>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/07/RUNDECK_oldui.jpg?w=1200&#038;ssl=1" alt="2.11.1버전의 로그인창" /></p>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/07/RUNDECK_oldproject.jpg?w=1200&#038;ssl=1" alt="2.11.1버전의 메인창" /></p>
<ul>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2019/07/23/rundeck-install-guide/">1편 : 런덱 설치 가이드</a></p>
</li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2019/07/24/rundeck-upgrade-guide/">2편 : 런덱 버전 업그레이드 가이드</a></p>
</li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2019/10/08/rundeck-deploy/">3편 : 런덱을 통한 배포 개선</a></p>
</li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2019/10/15/rundeck-workflow/">4편 : 런덱 워크플로우 정리</a></p>
</li>
</ul>
<h2>1. 기존 데이터 백업</h2>
<p>런덱은 크게 /var/lib 하위와 /etc 하위로 rundeck 이라는 폴더의 경로가 생깁니다.<br />
/var/lib 같은 경우는 설치 파일들이 있는 경로입니다.<br />
/etc 하위는 configure 파일들이 있는 경로입니다.</p>
<pre><code class="">- /var/lib/rudneck -> rudneck_bak (설치파일)
- /etc/rundeck -> rundeck_bak (config 파일) 
- DB는 RDS사용하며 DAILY BACKUP으로 따로 백업 하지 않음. 
  필자가 운영하는 런덱의 DB는 아마존 rds를 사용합니다. 기존의 h2 DB를 사용할시에는 다음의 경로를 백업합니다. 
/var/lib/rundeck/data/rundeckdb.mv.db
/var/lib/rundeck/data/rundeckdb.trace.db
</code></pre>
<h2>2. YUM Upgrade를 통한 패키지 업그레이드</h2>
<ul>
<li>기존 서비스 스탑</li>
</ul>
<pre><code class="">service rudneckd stop
</code></pre>
<ul>
<li>업그레이드 진행</li>
</ul>
<pre><code class="">기존에 rpm 패키지에 rudneck latest내용이 기입이 되어있어야 한다. 
rpm -Uvh http://repo.rundeck.org/latest.rpm
yum upgrade rundeck rundeck-config
</code></pre>
<p>인스톨을 진행하면 다음의 문구가 출력된다.</p>
<p>warning: /etc/rundeck/profile created as /etc/rundeck/profile.rpmnew<br />
warning: /etc/rundeck/rundeck-config.properties created as /etc/rundeck/rundeck-config.properties.rpmnew</p>
<p>기존의 파일을 대체하여 rpmnew라는 파일이 생성되고 해당 파일의 내용과 기존 파일의 내용을 merge해야된다.<br />
그러나, 필자가 확인해본결과 undeck-config.properties 파일의 grails.serverURL=http://{IP}:{PORT} 만 변경하면된다.</p>
<ul>
<li>컨피크파일 머지</li>
</ul>
<pre><code class="">기존파일 백업
cp rundeck-config.properties rundeck-config.properties_bak
      => 런덱 컨피그는 grails.serverURL=http://{IP}:4440 이내용만 변경 
cp framework.properties framework.properties_bak
cp profile profile_bak
나머지는 기존 파일 기반으로 생성되어, 동일하게 생성

신규 파일로 덮어쓰기
mv rundeck-config.properties.rpmnew rundeck-config.properties
mv framework.properties.rpmnew framework.properties
mv profile.rpmnew profile_bak  
</code></pre>
<ul>
<li>신규 서비스 기동</li>
</ul>
<pre><code class="">servcie rundeckd start
</code></pre>
<p>신규 서비스를 기동하고 /var/logs/rudneck/service.log 를 확인하여 정상기동되는지 체크한다.<br />
이후에 서비스 IP:PORT로 접속하여 확인합니다.</p>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/07/RUNDECK_newui.jpg?w=1200&#038;ssl=1" alt="3.0.24버전의 로그인창" /></p>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/07/RUNDECK_newproject.jpg?w=1200&#038;ssl=1" alt="3.0.24버전의 메인창" /></p>
<h2>3. 복구 계획</h2>
<p>만약 런덱 업그레이드를 하다가 실패를 하게 되면 어떻게 할까?<br />
신규 rpm 패키지를 체크하여 remove를 해준뒤, 기존 버전을 재설치 하는 방식으로 복구하고자 한다.</p>
<ul>
<li>신규 rpm 버전 체크</li>
</ul>
<pre><code class="">rpm -qa | grep rundeck
</code></pre>
<ul>
<li>yum 을 통한 remove</li>
</ul>
<pre><code class="">yum -y remove {패키지명}  -> rudneck rundeck-config 3.0.24 버전
</code></pre>
<ul>
<li>기존 버전 재설치</li>
</ul>
<pre><code class="">yum -y instlal rundeck-2.11.1-1.52.GA.noarch
yum -y install rundeck-config-2.11.1-1.52.GA.noarch
</code></pre>
<ul>
<li>파일 복구</li>
</ul>
<pre><code class="">백업했던 폴더를 통째로 엎어씁니다. 
mv /etc/rudneck_bak /etc/rundeck
mv /var/lib/rudneck_bak /var/lib/rundeck =>설치 파일은 재설치시 안해도되지만, 필요시 진행
</code></pre>
<p>이상으로 런덱 업그레이드를 알아봤습니다. UI적으로 좀더 깔끔해진 부분이 있는데 기능적으로는 크게 달라진점은 없는것 같네요.<br />
다음에 좀더 좋은 내용으로 찾아뵙겠습니다.</p>
<p><a href="http://blog.wonizz.com" title="워니즈 블로그">워니즈 블로그</a><br />
<a href="http://github.com/wonizz" title="워니즈 깃헙" target="_blank" rel="noopener">워니즈 깃헙</a></p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/07/24/rundeck-upgrade-guide/">[Rundeck] 런덱 업그레이드</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/07/24/rundeck-upgrade-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">586</post-id>	</item>
		<item>
		<title>[Rundeck] 설치 및 사용법</title>
		<link>https://blog.wonizz.com/2019/07/23/rundeck-install-guide/</link>
					<comments>https://blog.wonizz.com/2019/07/23/rundeck-install-guide/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Tue, 23 Jul 2019 08:00:54 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[DevOps]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=572</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>Rundeck 설치는 2026년 9월에도 공식 rpm-setup.sh 스크립트 한 줄과 yum 설치로 끝나고, 최신 버전은 6.2.1 입니다. 달라진 점은 Java 17 이상이 필수가 된 것과 정적 API 토큰에 역할까지 적어야 한다는 것이라 7절 표에 모아 두었습니다. 필자가 운영하는 프로젝트에서는 CI툴로는 Jenkins를 사용하고 CD툴로는 Rundeck을 사용한다. 소스는 IDC 서버에 있고, WAS 서버들이 아마존 웹서비스에 존재하다보니, 빌드를 한뒤&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/07/23/rundeck-install-guide/">[Rundeck] 설치 및 사용법</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>


<p class="wp-block-paragraph">Rundeck 설치는 2026년 9월에도 공식 rpm-setup.sh 스크립트 한 줄과 yum 설치로 끝나고, 최신 버전은 6.2.1 입니다. 달라진 점은 Java 17 이상이 필수가 된 것과 정적 API 토큰에 역할까지 적어야 한다는 것이라 7절 표에 모아 두었습니다.</p>

필자가 운영하는 프로젝트에서는 CI툴로는 Jenkins를 사용하고 CD툴로는 Rundeck을 사용한다. 소스는 IDC 서버에 있고, WAS 서버들이 아마존 웹서비스에 존재하다보니, 빌드를 한뒤 파일을 아마존쪽으로 전달해서 배포하는 형식이다.

라이브 배포툴로 사용하면 좋을 오픈소스 Rundeck에 대해서 정리한다.

<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/07/RUNDECK_main.jpg?w=1200&#038;ssl=1" alt="Rundeck 설치 및 사용법 설명 이미지 1" />

<a href="https://rundeck.org/" title="런덱 공식 URL" target="_blank" rel="noopener">런덱 공식 URL</a>

<ul>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2019/07/23/rundeck-install-guide/">1편 : 런덱 설치 가이드</a></p></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2019/07/24/rundeck-upgrade-guide/">2편 : 런덱 버전 업그레이드 가이드</a></p></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2019/10/08/rundeck-deploy/">3편 : 런덱을 통한 배포 개선</a></p></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2019/10/15/rundeck-workflow/">4편 : 런덱 워크플로우 정리</a></p></li>
</ul>

<h2 class="wp-block-heading">1. 설치</h2>

• 설치

<pre><code class="">curl https://raw.githubusercontent.com/rundeck/packaging/main/scripts/rpm-setup.sh 2&gt; /dev/null | sudo bash -s rundeck
sudo yum install java rundeck
</code></pre>

• 중지 및 기동

<pre><code class="">service rundeckd stop
service rundeckd start
</code></pre>

<h2 class="wp-block-heading">2. 런덱 기본 설정</h2>

<ul>
<li>hostname 변경

<pre><code class="">vi /etc/rundeck/rundeck-config.properties
grails.serverURL=http://xx.xx.xxx.xx:{port}  # Public IP 등록
</code></pre></li>
<li>admin 계쩡 설정

<pre><code class="">vi /etc/rundeck/realm.properties
admin:admin,user,admin,architect,deploy,build        
# admin 계정 패스워드 변경
</code></pre></li>
<li>Framework 설정

<pre><code class="">vi /etc/rundeck/framework.properties
framework.server.name = xx.xx.xxx.xx
framework.server.hostname = 0.0.0.0 
framework.server.port = {port}
framework.server.url = http://xx.xx.xxx.xx:{port} 
framework.rundeck.url = http://xx.xx.xxx.xx:{port}
</code></pre></li>
<li>영구 API 토근 설정 (필요시)

외부에서 API를 연계할일이 있어, API를 발급받아 사용했는데, 토큰 만료일자가 30일로 셋팅되어 매번 토근을 재발급받아야 했다. 
토근을 영구적으로 셋팅하기 위해서는 다음과 같이 하면된다.

<pre><code class="">vi /etc/rundeck/tokens.properties
Rundeck Web UI 의 Profile 메뉴에서 API Token 생성 후 등록
admin: {API_TOKEN}
</code></pre>

<p>2026년 9월 기준 공식 설정 문서로는 이 파일을 쓰려면 framework.properties 에 <code>rundeck.tokens.file=/etc/rundeck/tokens.properties</code> 로 경로를 지정해야 하고, 한 줄은 <code>admin: {API_TOKEN}, admin</code> 처럼 토큰 뒤에 역할을 붙이는 형식입니다. 자세한 내용은 7절에 적었습니다.</p>

<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/09/rundeck-user-api-tokens-masked.png?w=1200&#038;ssl=1" alt="Rundeck 설치 및 사용법 설명 이미지 2" />

</li>
<li>로그 셋팅

<pre><code class="">cd /etc/logrotate.d/
vi rundeck
vi rundeck-access
vi rundeck-api
vi rundeck-audit
vi rundeck-exec
vi rundeck-jobs
vi rundeck-options
vi rundeck-service
vi rundeck-storage

/var/log/rundeck/{파일명}.log {
      daily
      rotate 14
      compress
      delaycompress
      missingok
      notifempty
      create 0664 rundeck rundeck
}
</code></pre>

</li>
</ul>

<h2 class="wp-block-heading">3. 플러그인 설치</h2>

<pre><code class="">• /var/lib/rundeck/libext 경로에 Plug-In 파일 복사 후 재기동
openssh-node-execution-master.zip
rundeck-influxdb-annotation-step-plugin-master-0.1.0-SNAPSHOT.jar
rundeck-slack-incoming-webhook-plugin-0.6.jar
</code></pre>

<h2 class="wp-block-heading">4. 노드 접속 키 설정</h2>

<pre><code class="">• 노드 접속 Key 생성 ( password 방식 )
cd /var/lib/rundeck/var/storage/content
( rundeck 기동 후에 path 생성됨 )
mkdir keys
cd keys
vi {node_name}.password
{password}
</code></pre>

<h2 class="wp-block-heading">5. 노드 연결 확인</h2>

설치가 완료되면, 노드를 추가해야 해당 서버로 ssh 접속이 가능하게 된다.

<pre><code class="">vi /var/rundeck/projects/{프로젝트 명}/etc/resources.xml    ( 프로젝트 추가 후 생성됨 )
노드는 프로젝트별로 추가 필요
=> /var/rundeck/projects/resources.xml 로 통합하여 1개 파일만 수정하면 모든 프로젝트에 적용됨

추가할 노드 정보 입력 ( 예시 )
<?xml version="1.0" encoding="UTF-8"?>
<project>
<node name="TEST_A01"
      description="TEST_A01"
      tags="auth_a01"
      osFamily="unix"
      osName="Linux"
      hostname="10.0.xxx.xxxx:22"
      username="aemuser"
      sudo-command-enabled="true"
      scp-dir="/home/aemuser/"
      ssh-authentication="password"
      ssh-password-storage-path="keys/auth.password"
/>
</project>
</code></pre>

<h2 class="wp-block-heading">6. RSA 인증방식으로 설정</h2>

필자가 운영하는 프로젝트에서는 배포할 파일을 각 서버로 SCP하는 작업이 있었다. 그렇게 하기 위해서는 해당 서버로 SCP를 하기 위해 RSA 인증을 얻어야 하는데 다음과 같은 방식으로 인증을 획득한다.

<pre><code class="">1. 각 서버에서 키 생성 후, rundeck 서버에 publick key 등록 ( 패스워드 없이 scp 가능하도록 )
 - 대상 서버 : ssh-keygen -t rsa -b 2048
 - 생성된 rsa_id.pub 키 내용을 rundeck 서버 rundeck 계정 ~/.ssh/authorized_keys 에 추가 
   /var/lib/rundeck/.ssh/authorized_keys

2. 서버에서 scp 수동으로 1회 실행 ( 각 서버 → Rundeck 서버 )
</code></pre>

클라이언트에서 생성한 공개키 값을 접속하려는 서버의 authorized_keys 파일에 추가시키는 이유는 SSH 접속 시 client의 id_rsa.pub 키 값과 서버의 authorized_keys 값을 비교하여 인증을 진행하기 때문이다.

이상으로 런덱의 설치 및 운용방법에 대해서 알아보았다. 
런덱은 내부적으로 h2라는 db를 사용하는데, 보통 런덱을 업그레이드 하거나 백업을 할때는 다음의 경로를 백업 하면 된다.

<pre><code class="">       /var/lib/rundeck/data/rundeckdb.mv.db
       /var/lib/rundeck/data/rundeckdb.trace.db
</code></pre>

다음에는 각 JOB을 생성하는 방법에 대해서 알아보겠습니다.

<h2 class="wp-block-heading">7. 2026년 9월 기준으로 바뀐 설치 값은 무엇인가요?</h2>

<p>설치 순서는 그대로이고 Java 버전, 토큰 형식, 운영 DB 권고가 달라졌습니다. 2026년 9월 28일에 Rundeck 공식 문서와 GitHub 릴리스를 다시 열어 이 글의 값과 나란히 적어 보았습니다.</p>

<table>
<thead><tr><th>항목</th><th>이 글(2019년)</th><th>2026년 9월 기준</th></tr></thead>
<tbody>
<tr><td>최신 버전</td><td>버전 표기 없음</td><td>6.2.1 (2026-09-09 릴리스)</td></tr>
<tr><td>Java</td><td><code>yum install java</code> 로 버전 지정 없이 설치</td><td>6.0.0 부터 Java 17 이 최소, Java 25 까지 지원</td></tr>
<tr><td>설치 명령</td><td>rpm-setup.sh 스크립트, <code>yum install java rundeck</code></td><td>같은 스크립트와 명령이 공식 문서에 그대로 있음</td></tr>
<tr><td>기동과 첫 접속</td><td><code>service rundeckd start</code></td><td>공식 문서도 <code>sudo service rundeckd start</code>, 기본 주소 http://localhost:4440, 초기 계정 admin/admin</td></tr>
<tr><td>정적 API 토큰</td><td><code>admin: 토큰</code></td><td>framework.properties 에 <code>rundeck.tokens.file</code> 지정, <code>사용자: 토큰, 역할</code> 형식</td></tr>
<tr><td>UI 발급 토큰 만료</td><td>30일</td><td>기본 30d, <code>rundeck.api.tokens.duration.max</code> 로 변경</td></tr>
<tr><td>내장 DB</td><td>h2 (rundeckdb 파일)</td><td>기본 경로는 같음, 운영에는 외부 DB 권장</td></tr>
<tr><td>플러그인</td><td>libext 에 복사 후 재기동</td><td>libext 에 넣으면 재시작 없이 활성화</td></tr>
<tr><td>공식 사이트</td><td>rundeck.org</td><td>rundeck.org 는 www.rundeck.com 으로 이동, 문서는 docs.rundeck.com</td></tr>
</tbody>
</table>

<p>공식 문서는 Azul Zulu OpenJDK 로 빌드하고 테스트한다고 적고 있어서, 배포판 기본 java 패키지가 17 미만이라면 17 이상을 먼저 설치하고 <code>java -version</code> 으로 확인한 뒤 Rundeck 을 까는 편이 안전합니다. 이미 돌고 있는 서버를 올리는 경우라면 필자가 따로 정리한 <a href="https://blog.wonizz.com/2019/07/24/rundeck-upgrade-guide/">런덱 버전 업그레이드 절차</a>를 같이 보시면 됩니다.</p>

<h3>영구 API 토큰은 지금도 tokens.properties 로 만드나요?</h3>

<p>네, 지금도 tokens.properties 로 정적 토큰을 둘 수 있습니다. 다만 framework.properties 에 파일 경로를 적어야 읽히고, 각 줄에 사용자의 역할을 반드시 붙여야 합니다.</p>

<pre><code class="">vi /etc/rundeck/framework.properties
rundeck.tokens.file=/etc/rundeck/tokens.properties

vi /etc/rundeck/tokens.properties
admin: {API_TOKEN}, admin
</code></pre>

<p>웹 UI 에서 발급한 토큰의 기본 만료는 지금도 30일이고, rundeck-config.properties 의 <code>rundeck.api.tokens.duration.max</code> 로 기간을 바꿀 수 있습니다. 0 을 주면 만료가 없어지지만 공식 문서도 보안상 권하지 않는 설정입니다.</p>

<h3>H2 내장 DB 를 그대로 운영에 써도 되나요?</h3>

<p>운영에는 권하지 않습니다. 공식 문서는 H2 를 체험이나 중요하지 않은 용도로만 쓰라고 하고, Rundeck 이 정상 종료되지 않으면 안전하지 않다고 경고합니다. 운영 서버라면 MariaDB, MySQL, PostgreSQL 같은 외부 DB 로 옮기는 편이 맞습니다.</p>

<p>6절에 적은 백업 경로 <code>/var/lib/rundeck/data/rundeckdb</code> 는 지금 문서의 기본 dataSource.url 과 같아서, H2 를 쓰는 동안에는 그대로 유효합니다. 로그 파일 쪽은 <a href="https://blog.wonizz.com/2020/03/09/rundeck-rundeck-log-rotation/">Rundeck 로그 정리 방법</a>에 따로 적어 두었습니다.</p>

<h3>플러그인을 넣고 나면 꼭 재기동해야 하나요?</h3>

<p>지금 문서 기준으로는 재기동하지 않아도 됩니다. 플러그인 파일을 libext 디렉터리에 복사하면 바로 활성화되고, 파일을 지우면 제거된다고 안내합니다. 필자는 2019년에 재기동까지 했는데, 반영이 안 보일 때만 재기동으로 확인하시면 될 것 같습니다.</p>

<p>이 글처럼 빌드는 Jenkins 로, 배포는 Rundeck 으로 나누는 구성이라면 <a href="https://blog.wonizz.com/2019/08/04/jenkins-pipeline/">Jenkins 파이프라인 구성 방법</a>도 함께 참고하실 수 있습니다. 공식 설치 문서는 <a href="https://docs.rundeck.com/docs/administration/install/linux-rpm.html" target="_blank" rel="noopener">Rundeck RPM 설치 가이드</a>에 있습니다.</p>

<a href="https://rundeck.org/" title="런덱 공식 URL" target="_blank" rel="noopener">런덱 공식 URL</a>
<a href="http://github.com/wonizz" title="워니즈 깃헙" target="_blank" rel="noopener">워니즈 깃헙</a>


<h2 class="wp-block-heading" id="wonizz-faq">Rundeck 설치에 관해 자주 묻는 것</h2>



<p class="wp-block-paragraph"><strong>Q. Rundeck과 Jenkins는 무엇이 다른가요?</strong><br>Jenkins는 빌드를 담당하고 Rundeck은 배포와 운영 작업 실행을 담당합니다. 역할이 겹치지 않아 둘을 함께 쓰는 구성이 흔합니다.</p>



<p class="wp-block-paragraph"><strong>Q. 노드 연결이 안 될 때 가장 먼저 볼 것은 무엇인가요?</strong><br>SSH 키 파일의 권한과 소유자입니다. 권한이 600이 아니거나 rundeck 실행 계정이 그 키를 읽지 못하면 연결이 실패합니다. 대부분 여기서 막힙니다.</p>



<p class="wp-block-paragraph"><strong>Q. 지금도 이 방법이 유효한가요?</strong><br>설치, 노드 등록, 키 설정으로 이어지는 흐름은 그대로입니다. 다만 버전에 따라 설정 파일 경로가 다를 수 있어 공식 문서와 함께 보시는 편이 안전합니다.</p>




<h2 class="wp-block-heading" id="wonizz-related-block">함께 읽으면 좋은 글</h2>



<ul class="wp-block-list">

<li><a href="https://blog.wonizz.com/2020/04/20/rundck-plugin-1/">[Rundeck] Bastion Host Plugin 사용법</a>, 배스천을 거쳐야 하는 환경에서의 설정</li>


<li><a href="https://blog.wonizz.com/2021/06/21/devops-golang-grpc-server-1/">[DevOps] Golang gRPC 서버 구축하기 1편</a>, 같은 시기에 정리한 서버 구축 기록</li>

</ul>


<h2>런덱 API 토큰은 왜 매번 다시 발급해야 하나요?</h2>

<p>tokens.properties 에 토큰을 등록할 때 역할을 같이 적지 않으면 기본 만료 정책(30일)이 적용되기 때문입니다. 본문에서 정리했듯 <code>admin: {API_TOKEN}</code> 처럼 역할 없이 등록하면 주기적으로 재발급해야 하고, 역할까지 적어 등록하면 영구 토큰으로 동작합니다. 2026-09 기준 공식 설정 문서는 이 파일을 쓰려면 framework.properties 에 해당 파일 경로를 지정해야 한다는 점도 함께 확인했습니다.</p>

<p><em>최종 갱신 2026-10-16</em></p>

<p>AI 도구로 초안을 만들고 직접 실행·검증한 내용입니다.</p>

<div class="wz-next-read" style="margin:28px 0;padding:14px 18px;border:1px solid #e5e7eb;border-left:4px solid #f5a623;border-radius:6px;background:#fafafa;"><div style="font-weight:700;margin-bottom:6px;">이 글 다음에 읽을 글</div><ul style="margin:0;padding-left:20px;"><li><a href="https://blog.wonizz.com/2019/07/31/docker-dockerfile/?from=nr-572">[Docker] Dockerfile 의 이해</a>: Rundeck과 함께 쓰는 배포 파이프라인의 기초</li><li><a href="https://blog.wonizz.com/2019/07/29/docker-volume/?from=nr-572">[Docker] Volume 의 관리</a>: 컨테이너 배포 환경 구성 기록</li></ul></div>

<h2 class="wp-block-heading">함께 보면 좋은 글</h2>
<ul class="wp-block-list"><li><a href="https://blog.wonizz.com/2019/08/13/docker-compose/">[Docker] Compose 구성과 사용법</a></li><li><a href="https://blog.wonizz.com/2019/08/09/ansible-jinja2/">[Ansible] 앤서블 Jinja2 필터 사용법</a></li><li><a href="https://blog.wonizz.com/2019/08/08/ansible-role-include/">[Ansible] 플레이북 Role 과 Include</a></li></ul>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/07/23/rundeck-install-guide/">[Rundeck] 설치 및 사용법</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/07/23/rundeck-install-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">572</post-id>	</item>
		<item>
		<title>[Linux] Apache HTTP 서버와 Tomcat 서버의 연동</title>
		<link>https://blog.wonizz.com/2019/04/01/linux-apache-tomcat-connect/</link>
					<comments>https://blog.wonizz.com/2019/04/01/linux-apache-tomcat-connect/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Mon, 01 Apr 2019 10:06:21 +0000</pubDate>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=435</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>Apache HTTP 서버와 Tomcat 서버의 연동 Web Server인 Apache와 WAS 서버인 Tomcat 을 연동하는 방법에 대해 포스팅하겠습니다. 1. 아파치, 톰캣 연동의 이유 Tomcat은 WAS 서버이지만 Web 서버의 기능도 갖추고 있는 WAS 서버입니다. 그러나 톰캣의 Web 서버 기능은 아파치보다 느린 속도처리를 보였고, 이로 인해 정적인 페이지는 Apache가 처리하고, 동적인 페이지를 Tomcat이 처리함으로써 부하를 분산하는 이유에서 Apache와&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/04/01/linux-apache-tomcat-connect/">[Linux] Apache HTTP 서버와 Tomcat 서버의 연동</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<h1>Apache HTTP 서버와 Tomcat 서버의 연동</h1>

Web Server인 Apache와 WAS 서버인 Tomcat 을 연동하는 방법에 대해 포스팅하겠습니다.

<h2>1. 아파치, 톰캣 연동의 이유</h2>

Tomcat은 WAS 서버이지만 Web 서버의 기능도 갖추고 있는 WAS 서버입니다.

그러나 톰캣의 Web 서버 기능은 아파치보다 느린 속도처리를 보였고, 이로 인해

정적인 페이지는 Apache가 처리하고, 동적인 페이지를 Tomcat이 처리함으로써 부하를 분산하는 이유에서 Apache와 Tomcat을 연동하였습니다.

그러나 이는 옛날 얘기이고.. 지금은 Tomcat이 많이 발전해 Tomcat 내의 Web 서버가 아파치에 절대 뒤쳐지지
않을만큼의 역할을 수행합니다.
그럼에도 불구하고 아직도 Apache와 Tomcat을 연동하여 사용하는 이유는, 아파치 내에서만 설정할 수 있는 부분이라던가
아파치에서 제공하는 유용한 모듈들을 톰캣에서 사용할 수 없기 때문입니다.

<hr />

<ul>
<li>AJP, mod_jk

<ul>
<li>아파치와 톰캣이 연동하기 위해선 AJP를 통해 서로 통신을 하여야 합니다.</p></li>
<li>AJP란 아파치가 웹서버와 외부 서비스(톰캣 등)과 연동하기 위해 정한 규약(프로토콜) 입니다. 현재 1.3까지 나와있습니다.</p></li>
<li>아파치는 이를 사용하여 80포트로 들어오는 요청은 자신이 받고, 이 요청중 서블릿을 필요로 하는 요청은 톰캣에 접속하여 처리합니다.</p></li>
<li>우리는 아파치 톰캣 연동을 위해 mod_jk 라는 모듈을 사용할건데, 이는 AJP 프로토콜을 사용하여 톰캣과 연동하기 위해 만들어진 모듈입니다.</p></li>
</ul></li>
<li>처리 플로우

<ul>
<li>아파치 웹서버의 httpd.conf 에 톰캣 연동을 위한 설정을 추가하고 톰캣에서 처리할 요청을 지정함.</p></li>
<li>사용자의 브라우저는 아파치 웹서버(보통 80포트)에 접속해 요청</p></li>
<li>아파치 웹서버는 사용자의 요청이 톰캣에서 처리하도록 지정된 요청인지 확인. 요청을 톰캣에서 처리해야 하는 경우</p></li>
<li><p>아파치 웹서버는 톰캣의 AJP포트(보통 8009포트)에 접속해 요청을 전달</p></li>
<li><p>톰캣은 아파치 웹서버로부터 요청을 받아 처리한 후, 처리 결과를 아파치 웹서버에 되돌려줌</p></li>
<li><p>아파치 웹서버는 톰캣으로부터 받은 처리 결과를 사용자에게 전송</p></li>
</ul></li>
<li><p>톰캣 Server.xml 수정

server.xml

<pre><code class=""><!-- Define an AJP 1.3 Connector on port 8009 -->

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
</code></pre></li>
<li>아파치 workers.properties 수정

<pre><code class="">workers.properties
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
</code></pre>

<ul>
<li>ajp13 프로토콜을 사용하며, host는 localhost이며, 포트는 8009(아까 확인하셨죠?)를 사용합니다.</li>
</ul></li>
<li>아파치 http.conf 파일 수정

<pre><code class="">httpd.conf
LoadModule jk_module modules/mod_jk.so    // 모듈 위치
JkWorkersFile conf/workers.properties    // workers.properties 파일 위치
JkLogFile logs/mod_jk.log    // 로그파일 위치
JkLogLevel info    // 로그 레벨
JkMount /* worker1 -> JkMount 뒤에 오는 /* 는 모든 url의 요청을 의미
</code></pre></li>
<li>연동 테스트

http://localhost 로 접속

<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/04/1554113018734.png?w=1200&#038;ssl=1" alt="1554113018734" /></p></li>
</ul>

<p><a href="http://blog.wonizz.com" title="워니즈 블로그">워니즈 블로그</a>
<a href="http://github.com/wonizz" title="워니즈 깃헙" target="_blank" rel="noopener">워니즈 깃헙</a>
<h2 class="wp-block-heading">함께 보면 좋은 글</h2>
<ul class="wp-block-list"><li><a href="https://blog.wonizz.com/2019/04/01/linux-tomcat-server-config/">[Linux] 아파치 Tomcat Server.xml 설정</a></li><li><a href="https://blog.wonizz.com/2019/08/07/linux-sed/">[리눅스 명령어] sed 사용법</a></li><li><a href="https://blog.wonizz.com/2019/08/13/docker-compose/">[Docker] Compose 구성과 사용법</a></li><li><a href="https://blog.wonizz.com/2019/08/09/ansible-jinja2/">[Ansible] 앤서블 Jinja2 필터 사용법</a></li></ul>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/04/01/linux-apache-tomcat-connect/">[Linux] Apache HTTP 서버와 Tomcat 서버의 연동</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/04/01/linux-apache-tomcat-connect/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">435</post-id>	</item>
	</channel>
</rss>
