方法1:用提供的這個conpose文件,將這個文件放到/usr/local/bin
方法2:用epel和extra源中的安裝包
1)配置yum源php
[root@host1 ~]# cat /etc/yum.repos.d/epel.repo [epel] name=epel baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7Server/x86_64/ enabled=1 gpgcheck=0
2)安裝docker-composemysql
[root@host1 ~]# yum install docker-compose -y
先看一個dyml文件樣例
linux
image: redis image: ubuntu:14.04 image: tutum/influxdb image: example-registry.com:4000/postgresql image: a4bc65fd
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
tmpfs: - /run - /tmp
entrypoint: - php - -d - zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so - -d - memory_limit=-1 - vendor/bin/phpunit
env_file: - ./common.env - ./apps/web.env - /opt/secrets.env
environment: RACK_ENV: development SHOW: 'true' SESSION_SECRET:
environment:
- RACK_ENV=development
- SHOW=true
- SESSION_SECRETweb
#### 參數17:expose * 這個標籤與Dockerfile中的EXPOSE指令同樣,用於指定暴露的端口,可是隻是做爲一種參考 * 實際上docker-compose.yml的端口映射還得ports這樣的標籤。
expose:redis
external_links: - redis_1 - project_db_1:mysql - project_db_1:postgresql
extra_hosts: - "somehost:162.242.195.82" - "otherhost:50.31.209.229"
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: - db - db:database - redis
logging: driver: syslog options: syslog-address: "tcp://192.168.0.42:123"
ports: - "3000" - "8000:8000" - "49100:22" - "127.0.0.1:8001:8001"
security_opt: - label:user:USER - label:role:ROLE
volumes_from: - service_name - service_name:ro - container:container_name - container:container_name:rw
extends: file: common.yml service: webapp
network_mode: "bridge" network_mode: "host" network_mode: "none" network_mode: "service:[service name]" network_mode: "container:[container name/id]"
services: some-service: networks: - some-network - other-network
version: '2' services: web: build: . depends_on: - db - redis redis: image: redis db: image: postgres