ujm0 2020-05-08
compose说明
compose的安装
yum install python-pip -y pip install docker-compose pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ docker-compose docker-compose version
compose配置文件:/docker/compose/redis/docker-compose.yml
version: ‘2‘ services: redis: image: centos7:redis
compose操作容器
docker-compose exec的使用
docker-compose exec nginx bash
compose管理多个容器docker-compose.yml
version: ‘2‘ services: redis: image: centos7:redis nginx: image: centos7:nginx
compose使用端口映射
version: ‘2‘ services: redis: image: centos7:redis ports: - "6379:6379" nginx: image: centos7:nginx ports: - "8080:80" - "9090:80"
compose设置网络模式
version: ‘2‘ services: redis: image: centos7:redis nginx: image: centos7:nginx network_mode: "host
compose设置文件共享
version: ‘2‘ services: nginx: image: centos7:nginx network_mode: "host" volumes: - /centos7/logs:/usr/local/nginx/logs - /centos7/apps:/usr/local/nginx/html/apps
compose同个镜像启动多个容器