企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] > [参考](https://beginor.github.io/2017/06/08/use-compose-instead-of-run.html) ## demo ``` # PostGIS DB docker run \ --datach \ --publish 5432:5432 \ --name postgis \ --restart unless-stopped \ --volume $(pwd)/db/data:/var/lib/postgresql/data \ beginor/postgis:9.3 # GeoServer Web docker run \ --detach \ --publish 8080:8080 \ --name geoserver \ --restart unless-stopped \ --volume $(pwd)/geoserver/data_dir:/geoserver/data_dir \ --volume $(pwd)/geoserver/logs:/geoserver/logs \ --hostname geoserver \ --link postgis:postgis \ beginor/geoserver:2.11.0 ``` 等价于 docker-compose.yml ``` version: "3" services: web: image: beginor/geoserver:2.11.1 container_name: geoserver-web hostname: geoserver-web ports: - 8080:8080 volumes: - ./web/data_dir:/geoserver/data_dir - ./web/logs:/geoserver/logs restart: unless-stopped links: - database:database database: image: beginor/postgis:9.3 container_name: postgis hostname: postgis ports: - 5432:5432 volumes: - ./database/data:/var/lib/postgresql/data environment: POSTGRES_PASSWORD: 1q2w3e4R restart: unless-stopped ``` 启动 `docker-compose up -d` 停止 `docker-compose down`