十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
方法1:用提供的这个conpose文件,将这个文件放到/usr/local/bin
方法2:用epel和extra源中的安装包
1)配置yum源
[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-compose
[root@host1 ~]# yum install docker-compose -y
先看一个dyml文件样例
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_SECRET
#### 参数17:expose
* 这个标签与Dockerfile中的EXPOSE指令一样,用于指定暴露的端口,但是只是作为一种参考
* 实际上docker-compose.yml的端口映射还得ports这样的标签。
expose:
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
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。