赞
踩
- Docker-Compose项目是Docker官方的开源项目,负责实现对Docker容器集群的快速编排。
- Docker-Compose的工程配置文件默认为docker-compose.yml,可通过环境变量COMPOSE_FILE或-f参数自定义配置文件,其定义了多个有依赖关系的服务及每个服务运行的容器。
- Compose允许用户通过一个单独的docker-compose.yml模板文件(YAML 格式)来定义一组相关联的应用容器为一个项目(project)。
- Docker-Compose项目由Python编写,调用Docker服务提供的API来对容器进行管理。因此,只要所操作的平台支持Docker API, 就可以在其上利用Compose来进行编排管理。
创建文件夹:mkdir /etc/docker
跳转:cd /etc/docker
修改damon.json的内容:vim /etc/docker/daemon.json
{ "registry-mirrors": ["http://hub-mirror.c.163.com"] }
需要安装两个包(下载)
- docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm
- docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
两个包放在word里面了
把两个包放入到/home下面
然后进入安装:
输入:yum install docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm
输入:yum install docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
查看docker服务:systemctl status docker
设置开启自启docker服务:systemctl enable docker
启动docker服务:systemctl start docker
查看命令:docker version
下载:docker-compose-Linux-x86_64
创建:docker-compose.yml
拷贝docker-compose-Linux-x86_64到/usr/local/bin/并改名:mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
添加权限:chmod +x /usr/local/bin/docker-compose
查看版本:docker-compose -v
- version: '3'
- services:
- mysql:
- restart: always
- image: mysql:8.0.26
- container_name: mysqld
- volumes:
- - /home/mysql/logs:/logs
- - /home/mysql/datadir:/var/lib/mysql
- - /home/mysql/conf:/etc/mysql/conf.d
- - /home/mysql/my.cnf:/etc/mysql/my.cnf
- # 数据库还原目录 可将需要还原的sql文件放在这里
- - /home/mysql/source:/docker-entrypoint-initdb.d
- environment:
- - "MYSQL_ROOT_PASSWORD=123456"
- - "TZ=Asia/Shanghai"
- command:
- --default-authentication-plugin=mysql_native_password
- --lower_case_table_names=1
- ports:
- # 使用宿主机的3306端口映射到容器的3306端口
- # 宿主机:容器
- - 13306:3306
- networks:
- Energynetwork:
- ipv4_address: 192.168.1.10
- postgresql:
- restart: always
- image: postgres:12
- container_name: pg_base
- privileged: true
- volumes:
- - ./pgsql/datadir:/var/lib/postgresql/data
- environment:
- - PGDATA=/var/lib/postgresql/data/pgdata
- - POSTGRES_PASSWORD=Aa12345678
- - POSTGRES_DB=inventory
- - TZ=Asia/Shanghai
- ports:
- - 5432:5432
- sqlserver:
- image: mcr.microsoft.com/mssql/server:latest
- container_name: sqlserver
- ports:
- - 1433:1433
- volumes:
- - ./mssql:/var/opt/mssql
- - /etc/localtime:/etc/localtime
- restart: always
- environment:
- #接受最终用户许可协议
- - ACCEPT_EULA=Y
- #SA用户密码
- - SA_PASSWORD=Aa123456@
- oracle:
- restart: always
- image: registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:latest
- container_name: oracle_base
- privileged: true
- volumes:
- - /etc/localtime:/etc/localtime
- - ./oracle/data:/opt/oracle/oradata
- environment:
- - TZ=Asia/Shanghai
- - ORACLE_SID=XE
- - ORACLE_PDB=system
- - ORACLE_PWD=oracle
- ports:
- - 1521:1521
-
-
- networks:
- Energynetwork:
- driver: bridge
- ipam:
- config:
- - subnet: "192.168.1.0/24"
启动:docker-compose up -d
停止:docker-compose down
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。