Docker Compose 시도
Docker는 4월 Machine, Swarm, Compose 세 가지 기능을 발표했다.(참조)
ANNOUNCING DOCKER MACHINE, SWARM, AND COMPOSE FOR ORCHESTRATING DISTRIBUTED APPS
http://blog.docker.com/2014/12/announcing-docker-machine-swarm-and-compose-for-orchestrating-distributed-apps/
Docker Advent Calendar 17일차는 맥시진, 스웩의 기사이기 때문에 이번에는 컴포즈를 해보고 싶어요.
Compose 소개
Fig에서 영감을 받은 프로젝트인 것 같습니다.
아울러 발표한 머신, 스warm, Compose의 입장은 다음과 같다.
하지만 아직 개발 중이며 컴포지이쪽 지허브 이수스.가 교환됐다.
Compose를 시도하려면
Github Issues에 적힌 대로 해 보세요.
이번에 시도한 Compose의 명령 자체가 Docker client의 일부입니다.
우선 boot2 docker의 VM 내 Docker와 수중에 있는 Docker client 버전1.3.2-dev
이 있습니다.
먼저 VM 내에서 시작합니다.$ boot2docker ssh
docker@boot2docker:~$ sudo -i
root@boot2docker:~# curl -LO http://cl.ly/0Q3G1l2t301S/download/docker-1.3.2-dev-linux
root@boot2docker:~# /etc/init.d/docker stop
root@boot2docker:~# mv /usr/local/bin/docker ./docker-stable
root@boot2docker:~# mv ./docker-1.3.2-dev-linux /usr/local/bin/docker
root@boot2docker:~# chmod +x /usr/local/bin/docker
root@boot2docker:~# /etc/init.d/docker start
root@boot2docker:~# docker version
docker@boot2docker:~$ docker version
Client version: 1.3.2-dev
Client API version: 1.16
Go version (client): go1.3.3
Git commit (client): c6bf574
OS/Arch (client): linux/amd64
Server version: 1.3.2-dev
Server API version: 1.16
Go version (server): go1.3.3
Git commit (server): c6bf574
root@boot2docker:~# exit
docker@boot2docker:~$ exit
다음은 수중에 있는 Docker client 입니다.$ curl -LO http://cl.ly/1J1G323h3d3T/download/docker-1.3.2-dev-darwin-amd64
$ mv /usr/local/bin/docker ./docker-stable
$ mv ./docker-1.3.2-dev-darwin-amd64 /usr/local/bin/docker
$ chmod +x /usr/local/bin/docker
$ docker version
Client version: 1.3.2-dev
Client API version: 1.16
Go version (client): go1.3.3
Git commit (client): c6bf574
OS/Arch (client): darwin/amd64
Server version: 1.3.2-dev
Server API version: 1.16
Go version (server): go1.3.3
Git commit (server): c6bf574
이것으로 끝낼 준비를 하다.
Redis를 사용하여 액세스 카운터가 있는 웹 사이트를 구축합니다.
Compose에서는 group.yml
에 구성에 대해 기술합니다.
group.ymlname: counter
containers:
web:
build: .
command: python app.py
ports:
- "5000:5000"
volumes:
- .:/code
links:
- redis
environment:
- PYTHONUNBUFFERED=1
redis:
image: redis:latest
command: redis-server --appendonly yes
다음은 web
에 정의된 웹 서버의 코드입니다.
app.pyfrom flask import Flask
from redis import Redis
app = Flask(__name__)
redis = Redis(host="redis", port=6379)
@app.route('/')
def hello():
redis.incr('hits')
return 'Hello World! I have been seen %s times.' % redis.get('hits')
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)
requirements.txtflask
redis
그리고 웹 서버의 Docker file을FROM python:2.7
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
준비 완료!docker up
시동!$ docker up
Recreating redis
Starting redis
Recreating web
Starting web
redis | _._
redis | _.-``__ ''-._
redis | _.-`` `. `_. ''-._ Redis 2.8.18 (00000000/0) 64 bit
redis | .-`` .-```. ```\/ _.,_ ''-._
redis | ( ' , .-` | `, ) Running in stand alone mode
redis | |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
redis | | `-._ `._ / _.-' | PID: 8
redis | `-._ `-._ `-./ _.-' _.-'
redis | |`-._`-._ `-.__.-' _.-'_.-'|
redis | | `-._`-._ _.-'_.-' | http://redis.io
redis | `-._ `-._`-.__.-'_.-' _.-'
redis | |`-._`-._ `-.__.-' _.-'_.-'|
redis | | `-._`-._ _.-'_.-' |
redis | `-._ `-._`-.__.-'_.-' _.-'
redis | `-._ `-.__.-' _.-'
redis | `-._ _.-'
redis | `-.__.-'
redis |
redis | [8] 18 Dec 08:19:20.335 # Server started, Redis version 2.8.18
redis | [8] 18 Dec 08:19:20.336 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis | [8] 18 Dec 08:19:20.336 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis | [8] 18 Dec 08:19:20.336 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis | [8] 18 Dec 08:19:20.336 * The server is now ready to accept connections on port 6379
web | * Running on http://0.0.0.0:5000/
web | * Restarting with reloader
브라우저에서 http://(boot2dockerVMのIP):5000
$ open http://$(boot2docker ip):5000
재부팅 후 계수가 증가합니다.
Docker의 로그를 보았습니다. 방문 로그가 잘 있습니다.web | 192.168.59.3 - - [18/Dec/2014 08:19:36] "GET / HTTP/1.1" 200 -
즉
현재 상태는 Fig과 같습니다.
멀티-Hosts 같은 것도 간단해졌으면 좋겠어요.
Reference
이 문제에 관하여(Docker Compose 시도), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/hideyuki/items/bf372c521379fd43b42a
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
$ boot2docker ssh
docker@boot2docker:~$ sudo -i
root@boot2docker:~# curl -LO http://cl.ly/0Q3G1l2t301S/download/docker-1.3.2-dev-linux
root@boot2docker:~# /etc/init.d/docker stop
root@boot2docker:~# mv /usr/local/bin/docker ./docker-stable
root@boot2docker:~# mv ./docker-1.3.2-dev-linux /usr/local/bin/docker
root@boot2docker:~# chmod +x /usr/local/bin/docker
root@boot2docker:~# /etc/init.d/docker start
root@boot2docker:~# docker version
docker@boot2docker:~$ docker version
Client version: 1.3.2-dev
Client API version: 1.16
Go version (client): go1.3.3
Git commit (client): c6bf574
OS/Arch (client): linux/amd64
Server version: 1.3.2-dev
Server API version: 1.16
Go version (server): go1.3.3
Git commit (server): c6bf574
root@boot2docker:~# exit
docker@boot2docker:~$ exit
$ curl -LO http://cl.ly/1J1G323h3d3T/download/docker-1.3.2-dev-darwin-amd64
$ mv /usr/local/bin/docker ./docker-stable
$ mv ./docker-1.3.2-dev-darwin-amd64 /usr/local/bin/docker
$ chmod +x /usr/local/bin/docker
$ docker version
Client version: 1.3.2-dev
Client API version: 1.16
Go version (client): go1.3.3
Git commit (client): c6bf574
OS/Arch (client): darwin/amd64
Server version: 1.3.2-dev
Server API version: 1.16
Go version (server): go1.3.3
Git commit (server): c6bf574
name: counter
containers:
web:
build: .
command: python app.py
ports:
- "5000:5000"
volumes:
- .:/code
links:
- redis
environment:
- PYTHONUNBUFFERED=1
redis:
image: redis:latest
command: redis-server --appendonly yes
from flask import Flask
from redis import Redis
app = Flask(__name__)
redis = Redis(host="redis", port=6379)
@app.route('/')
def hello():
redis.incr('hits')
return 'Hello World! I have been seen %s times.' % redis.get('hits')
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)
flask
redis
FROM python:2.7
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
$ docker up
Recreating redis
Starting redis
Recreating web
Starting web
redis | _._
redis | _.-``__ ''-._
redis | _.-`` `. `_. ''-._ Redis 2.8.18 (00000000/0) 64 bit
redis | .-`` .-```. ```\/ _.,_ ''-._
redis | ( ' , .-` | `, ) Running in stand alone mode
redis | |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
redis | | `-._ `._ / _.-' | PID: 8
redis | `-._ `-._ `-./ _.-' _.-'
redis | |`-._`-._ `-.__.-' _.-'_.-'|
redis | | `-._`-._ _.-'_.-' | http://redis.io
redis | `-._ `-._`-.__.-'_.-' _.-'
redis | |`-._`-._ `-.__.-' _.-'_.-'|
redis | | `-._`-._ _.-'_.-' |
redis | `-._ `-._`-.__.-'_.-' _.-'
redis | `-._ `-.__.-' _.-'
redis | `-._ _.-'
redis | `-.__.-'
redis |
redis | [8] 18 Dec 08:19:20.335 # Server started, Redis version 2.8.18
redis | [8] 18 Dec 08:19:20.336 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis | [8] 18 Dec 08:19:20.336 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis | [8] 18 Dec 08:19:20.336 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis | [8] 18 Dec 08:19:20.336 * The server is now ready to accept connections on port 6379
web | * Running on http://0.0.0.0:5000/
web | * Restarting with reloader
$ open http://$(boot2docker ip):5000
web | 192.168.59.3 - - [18/Dec/2014 08:19:36] "GET / HTTP/1.1" 200 -
현재 상태는 Fig과 같습니다.
멀티-Hosts 같은 것도 간단해졌으면 좋겠어요.
Reference
이 문제에 관하여(Docker Compose 시도), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/hideyuki/items/bf372c521379fd43b42a텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)