Linux

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > Linux > Linux安装Docker-Compose

Linux安装Docker-Compose过程

作者:Heerlen

文章介绍了在Linux系统上安装Docker Compose的步骤,包括使用curl从GitHub下载Docker Compose二进制文件并保存到/usr/local/bin目录,然后通过chmod命令增加执行权限

Linux安装Docker-Compose

docker-compose官网文档

Docker-Compose安装

sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

备注:安装完成之后此时会提示权限不足,需要增加执行权限

增加Docker-Compose权限

sudo chmod +x /usr/local/bin/docker-compose

Linux安装docker-compose编排工具并启动

Docker Compose是什么

安装

先查看是否有没有docker(并没有发现安装docker)

开始安装docker

1. 先创建demon.json

{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}

2.安装docker

需要安装两个包

两个包放在word里面了

把两个包放入到/home下面

然后进入安装:

3.安装docker-compose编排工具

4.安装mysql,pgsql,oracle,sqlserver

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"

5.启动docker-compose

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文