docker - compose 명령 및 Yml 파일
docker-compose up -d nginx nignx
docker-compose exec nginx bash nginx
docker-compose down nginx ,
docker-compose ps
docker-compose restart nginx nginx
docker-compose run --no-deps --rm php-fpm php -v php-fpm , php -v
docker-compose build nginx 。
docker-compose build --no-cache nginx 。
docker-compose logs nginx nginx
docker-compose logs -f nginx nginx
docker-compose config -q (docker-compose.yml) , , , , 。
docker-compose events --json nginx json nginx docker
docker-compose pause nginx nignx
docker-compose unpause nginx ningx
docker-compose rm nginx ( )
docker-compose stop nginx nignx
docker-compose start nginx nignx
docker-compose.ymal
홈 페이지 예제:
version: "3.7"
services:
redis:
image: redis:alpine
ports:
- "6379"
networks:
- frontend
deploy:
replicas: 2
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
db:
image: postgres:9.4
volumes:
- db-data:/var/lib/postgresql/data
networks:
- backend
deploy:
placement:
constraints: [node.role == manager]
vote:
image: dockersamples/examplevotingapp_vote:before
ports:
- "5000:80"
networks:
- frontend
depends_on:
- redis
deploy:
replicas: 2
update_config:
parallelism: 2
restart_policy:
condition: on-failure
result:
image: dockersamples/examplevotingapp_result:before
ports:
- "5001:80"
networks:
- backend
depends_on:
- db
deploy:
replicas: 1
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
worker:
image: dockersamples/examplevotingapp_worker
networks:
- frontend
- backend
deploy:
mode: replicated
replicas: 1
labels: [APP=VOTING]
restart_policy:
condition: on-failure
delay: 10s
max_attempts: 3
window: 120s
placement:
constraints: [node.role == manager]
visualizer:
image: dockersamples/visualizer:stable
ports:
- "8080:8080"
stop_grace_period: 1m30s
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
placement:
constraints: [node.role == manager]
networks:
frontend:
backend:
volumes:
db-data:
부분 분해
##
services:
web:
image: hello-world
## dockerfile
build: /path/to/build/dir
build: ./dir
build:
context: ../
dockerfile: path/of/Dockerfile
build: ./dir
image: webapp:tag
##command
command
command: bundle exec thin -p 3000
command: [bundle, exec, thin, -p, 3000]
##container_name
Compose :
、 , ,
container_name: app
##depends_on
depends_on 、
version: '2'
services:
web:
build: .
depends_on:
- db
- redis
redis:
image: redis
db:
##dns
dns: 8.8.8.8
dns:
- 8.8.8.8
- 9.9.9.9
dns_search: example.com
dns_search:
- dc1.example.com
- dc2.example.com
##tmfs
, run
tmpfs: /run
tmpfs:
- /run
- /tmp
##environment
, ,
environment:
RACK_ENV: development
SHOW: 'true'
SESSION_SECRET:
environment:
- RACK_ENV=development
- SHOW=true
- SESSION_SECRET
##expose
, , ports
expose:
- "3000"
- "8000"
##external_links
Docker , docker run , Compose docker-compose.yml , , external_links, Compose ( )
external_links:
- redis_1
- project_db_1:mysql
- project_db_1:postgresql
##extra_hosts
, /etc/hosts
extra_hosts:
- "somehost:162.242.195.82"
- "otherhost:50.31.209.229"
##labels
, Dockerfile lable
labels:
com.example.description: "Accounting webapp"
com.example.department: "Finance"
com.example.label-with-empty-value: ""
labels:
- "com.example.description=Accounting webapp"
- "com.example.department=Finance"
- "com.example.label-with-empty-value"
##links
, docker –link , , /etc/hosts
links:
- db
- db:database
- redis
##ports
HOST:CONTAINER ,
ports:
- "3000"
- "8000:8000"
- "49100:22"
- "127.0.0.1:8001:8001"
HOST:CONTAINER , 60 , YAML xx:yy 60 。
##security_opt
。 , user USER
security_opt:
- label:user:USER
- label:role:ROLE
##volumes
, [HOST:CONTAINER] , [HOST:CONTAINER:ro] , , , 。
compose , . …
volumes:
// ,Docker ( )。
- /var/lib/mysql
//
- /opt/data:/var/lib/mysql
// Compose 。
- ./cache:/tmp/cache
// (~/ /home// /root/)。
- ~/configs:/etc/configs/:ro
// 。
- datavolume:/var/lib/mysql
, volume_driver。
volume_driver: mydriver
##volumes_from
, :ro :rw, , ,
volumes_from:
- service_name
- service_name:ro
- container:container_name
- container:container_name:rw
##network_mode
, docker client –net , service:[sevice name]
network_mode: "bridge"
network_mode: "host"
network_mode: "none"
network_mode: "service:[service name]"
network_mode: "container:[container name/id]"
##networks
services:
some-service:
networks:
- some-network
- other-network
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.