docker-compose

创建 docker-compose.yml 文件

version: 3
services:
	nginx:
		image: nginx
		ports:
			- "8080:80"
		networks:
			- "otest"
		volumes:
			- nest:/mnt
networks:
	otest:
		driver: bridge
volumes:
	nest:
		driver: local

启动

docker-compose up
docker-compose up -d

docker-compose up 会创建默认的网络

查看

docker-compose ps

exec

docker-compose exec web /bin/bash

停止

docker-compose stop # 后面跟服务名则只停止具体的服务

删除

docker-compose rm

rm 不会删除掉创建的网络和数据卷

同时删除掉网络

docker-compose down