您好,登录后才能下订单哦!
这篇文章给大家分享的是有关docker-compose怎么用的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
The Compose file is a YAML file defining services, networks and volumes. A service definition contains configuration that is applied to each container started for that service, much like passing command-line parameters to
docker run
. Likewise, network and volume definitions are analogous todocker network create
anddocker volume create
.As withdocker run
, options specified in the Dockerfile, such asCMD
,EXPOSE
,VOLUME
,ENV
, are respected by default - you don’t need to specify them again indocker-compose.yml
.
文档上这段话已经概括了docker-compose编排文件的写法。一个yaml的编排文件定义了 services, networks and volumes,service定义的配置其实就是docker run
命令的参数,同理network and volume定义的是docker network create
,docker volume create
命令,在dockerfile文件中有的诸如CMD
, EXPOSE
, VOLUME
, ENV
命令则不需要重新定义。剩下的需要什么找什么命令就好了。
创建一个名为kong-net
,桥接模式的network,将3个容器加入进来,其中kong
容器是使用dockerfile构建,db和konga
使用远程仓库镜像,kong
的启动在db
之后,konga
的启动在kong
之后。
version: '3' services: kong: container_name: kong-dapeng environment: - KONG_DATABASE=postgres - KONG_PG_HOST=kong-database - KONG_PG_PASSWORD=kong - KONG_PROXY_ACCESS_LOG=/dev/stdout - KONG_ADMIN_ACCESS_LOG=/dev/stdout - KONG_PROXY_ERROR_LOG=/dev/stderr - KONG_ADMIN_ERROR_LOG=/dev/stderr - KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl - KONG_PLUGINS=bundled,router-by-jwt-claim,jwt-dapeng,kafka-log build: . ports: - "80:8000" - "8001:8001" networks: - kong-net depends_on: - db db: container_name: kong-database image: "postgres:9.6" ports: - "5432:5432" environment: - POSTGRES_USER=kong - POSTGRES_DB=kong - POSTGRES_PASSWORD=kong volumes: - /dockerV/postgres:/var/lib/postgresql/data networks: - kong-net konga: container_name: konga image: "pantsel/konga" ports: - "1337:1337" environment: - DB_ADAPTER=postgres - DB_HOST=kong-database - DB_PORT=5432 - DB_USER=kong - DB_PASSWORD=kong - DB_DATABASE=konga networks: - kong-net depends_on: - kong networks: kong-net: driver: bridge
感谢各位的阅读!关于“docker-compose怎么用”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。