【Docker】공식 튜토리얼을 해 보았다 【Part3】
9123 단어 docker-compose도커DockerHub
소개
환경
튜토리얼
Part 2: Containers
Part 3: Services
Part 4: Swarms
Part 3: Services
docker-compose.yml 만들기
docker-compose.yml
version: "3"
services:
web:
# Part2で作成したdocker cloudのイメージを使用
image: tocyuki/repository:tag
deploy:
# 5台作成する
replicas: 5
resources:
limits:
# 最大10%までのCPU利用
cpus: "0.1"
# 最大50MBまでのメモリ利用
memory: 50M
restart_policy:
condition: on-failure
ports:
# ホストの80番ポートをコンテナの80番ポートへマッピング
- "80:80"
networks:
- webnet
networks:
webnet:
docker swarm init 구현
tocyuki@vm01:~/docker_tutorial/part3$ docker swarm init
Swarm initialized: current node (mfb7mslrjr6qbkkzi42x9525p) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-3562frmookuker51re8lelyaewh1c37g690yodforc13gxhby6-3gntbpftwe8br3h225i5ew7ul \
10.0.2.15:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
앱 실행
getstartedlab이라는 이름으로 swarm 모드로 앱을 실행합니다.
tocyuki@vm01:~/docker_tutorial/part3$ docker stack deploy -c docker-compose.yml getstartedlab
Creating network getstartedlab_webnet
Creating service getstartedlab_web
컨테이너 시작 확인
명령줄에서 확인
tocyuki@vm01:~/docker_tutorial/part3$ docker stack ps getstartedlab
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
msazmhxdrs9z getstartedlab_web.1 tocyuki/repository:tag vm01 Running Running 4 seconds ago
4bz3usxe0fpa getstartedlab_web.2 tocyuki/repository:tag vm01 Running Running 4 seconds ago
js4j0zhxaydu getstartedlab_web.3 tocyuki/repository:tag vm01 Running Running 5 seconds ago
5rdhkuc5xkns getstartedlab_web.4 tocyuki/repository:tag vm01 Running Running 4 seconds ago
p3tqe5lhu9zg getstartedlab_web.5 tocyuki/repository:tag vm01 Running Running 4 seconds ago
tocyuki@vm01:~/docker_tutorial/part3$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
49ffec8732f5 tocyuki/repository@sha256:1ae82dcb5528f752c9c1fc57a55ec0dde097ee2b119011ed2d99b3b9e81228d8 "python app.py" 3 minutes ago Up 3 minutes 80/tcp getstartedlab_web.4.5rdhkuc5xknsyeru01160pang
7f105ebe27ed tocyuki/repository@sha256:1ae82dcb5528f752c9c1fc57a55ec0dde097ee2b119011ed2d99b3b9e81228d8 "python app.py" 3 minutes ago Up 3 minutes 80/tcp getstartedlab_web.5.p3tqe5lhu9zgh1atrwe7svk59
485d12957ac6 tocyuki/repository@sha256:1ae82dcb5528f752c9c1fc57a55ec0dde097ee2b119011ed2d99b3b9e81228d8 "python app.py" 3 minutes ago Up 3 minutes 80/tcp getstartedlab_web.1.msazmhxdrs9z75379ojwkgmgj
a55408bffb42 tocyuki/repository@sha256:1ae82dcb5528f752c9c1fc57a55ec0dde097ee2b119011ed2d99b3b9e81228d8 "python app.py" 3 minutes ago Up 3 minutes 80/tcp getstartedlab_web.3.js4j0zhxaydun9wwv9xqtew5c
c2d0e23af466 tocyuki/repository@sha256:1ae82dcb5528f752c9c1fc57a55ec0dde097ee2b119011ed2d99b3b9e81228d8 "python app.py" 3 minutes ago Up 3 minutes 80/tcp getstartedlab_web.2.4bz3usxe0fpaxsy0q9qi3ai53
WEB 브라우저에서 확인
앱 종료
tocyuki@vm01:~/docker_tutorial/part3$ docker stack rm getstartedlab
Removing service getstartedlab_web
Removing network getstartedlab_webnet
Part3에서 배운 명령의 치트 시트
# List all running applications on this Docker host
docker stack ls
# Run the specified Compose file
docker stack deploy -c <composefile> <appname>
# List the services associated with an app
docker stack services <appname>
# List the running containers associated with an app
docker stack ps <appname>
# Tear down an application
docker stack rm <appname>
Reference
이 문제에 관하여(【Docker】공식 튜토리얼을 해 보았다 【Part3】), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/Tocyuki/items/2b04a0fcf25c07c1b367텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)