docker-compose.yml(1)

docker-compose 常用命令

Commands:
build Build or rebuild services
bundle Generate a Docker bundle from the Compose file
config Validate and view the compose file
create Create services
down Stop and remove containers, networks, images, and volumes
events Receive real time events from containers
exec Execute a command in a running container
help Get help on a command
kill Kill containers
logs View output from containers
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pull service images
push Push service images
restart Restart services
rm Remove stopped containers
run Run a one-off command
scale Set number of containers for a service
start Start services
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker-Compose version information

解释一下
build 构建或重建服务
help 命令帮助
kill 杀掉容器
logs 显示容器的输出内容
port 打印绑定的开放端口
ps 显示容器
pull 拉取服务镜像
restart 重启服务
rm 删除停止的容器
run 运行一个一次性命令
scale 设置服务的容器数目
start 开启服务
stop 停止服务
up 创建并启动容器

实例1
version: '3'
services:
zookeeper-1:
image: zookeeper
network_mode: "host"
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=java-test:2888:3888
redis-server:
image: redis
network_mode: "host"
volumes:
- /var/redis/data:/data
command: ["redis-server", "--appendonly", "yes"]
solr:
image: "solr:5.5"
network_mode: "host"
volumes:
- /var/solr/jarvis-test:/opt/solr/server/solr/jarvis-test
- /var/solr/lib:/opt/solr/server/solr/lib
~

原文地址:https://www.cnblogs.com/luoyan01/p/9734134.html