首页 > 其他分享 >42_Docker容器编排

42_Docker容器编排

时间:2024-03-13 10:55:16浏览次数:25  
标签:COMMENT compose 42 redis 编排 mysql services docker Docker

  1. 下载安装 docker-compose
curl -L "https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# curl -L "https://get.daocloud.io/docker/compose/releases/download/v2.17.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

# 卸载
rm -rf /usr/local/bin/docker-compose
  1. 常用命令
Compose常用命令
docker-compose -h                           # 查看帮助
docker-compose up                           # 启动所有docker-compose服务
docker-compose up -d                        # 启动所有docker-compose服务并后台运行
docker-compose down                         # 停止并删除容器、网络、卷、镜像.
docker-compose exec  yml里面的服务id         # 进入容器实例内部  docker-compose exec docker-compose.yml文件中写的服务id /bin/bash
docker-compose ps                           # 展示当前docker-compose编排过的运行的所有容器
docker-compose top                          # 展示当前docker-compose编排过的容器进程
docker-compose logs  yml里面的服务id         # 查看容器输出日志
docker-compose config     # 检查配置
docker-compose config -q  # 检查配置, 有问题才有输出
docker-compose restart    # 重启服务
docker-compose start      # 启动服务
docker-compose stop       # 停止服务

Commands:
  build              Build or rebuild services
  config             Validate and view the Compose file
  create             Create services
  down               Stop and remove resources
  events             Receive real time events from containers
  exec               Execute a command in a running container
  help               Get help on a command
  images             List images
  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 version information and quit
  1. 创建用户表
CREATE TABLE `t_user` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL DEFAULT '' COMMENT '用户名',
  `password` varchar(50) NOT NULL DEFAULT '' COMMENT '密码',
  `sex` tinyint(4) NOT NULL DEFAULT '0' COMMENT '性别 0=女 1=男 ',
  `deleted` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '删除标志, 默认0不删除, 1删除',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='用户表'
  1. docker-compose.yml 模板
version: "3"
 
services:
  microService:
    image: zzyy_docker:1.6
    container_name: ms01
    ports:
      - "6001:6001"
    volumes:
      - /app/microService:/data
    networks:
      - atguigu_net
    depends_on: # 依赖于这两个先启动
      - redis
      - mysql
 
  redis:
    image: redis:6.0.8
    ports:
      - "6379:6379"
    volumes:
      - /app/redis/redis.conf:/etc/redis/redis.conf
      - /app/redis/data:/data
    networks:
      - atguigu_net
    command: redis-server /etc/redis/redis.conf
 
  mysql:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: '123456'
      MYSQL_ALLOW_EMPTY_PASSWORD: 'no'
      MYSQL_DATABASE: 'db2021'
      MYSQL_USER: 'zzyy'
      MYSQL_PASSWORD: 'zzyy123'
    ports:
       - "3306:3306"
    volumes:
       - /app/mysql/db:/var/lib/mysql
       - /app/mysql/conf/my.cnf:/etc/my.cnf
       - /app/mysql/init:/docker-entrypoint-initdb.d
    networks:
      - atguigu_net
    command: --default-authentication-plugin=mysql_native_password #解决外部无法访问
 
networks:
   atguigu_net:

标签:COMMENT,compose,42,redis,编排,mysql,services,docker,Docker
From: https://www.cnblogs.com/ckh2023/p/18070155

相关文章

  • 数据收发卡设计方案:428-基于XC7Z100+ADRV9009的双收双发无线电射频板卡 5G小基站 无线
    基于XC7Z100+ADRV9009的双收双发无线电射频板卡一、板卡概述    基于XC7Z100+ADRV9009的双收双发无线电射频板卡是基于Xilinx ZYNQ FPGA和ADI的无线收发芯片ADRV9009开发的专用功能板卡,用于5G小基站,无线图传,数据收发等领域。 二、板卡原理及功能   板卡使用XC......
  • docker it 多条命令
    目录Dockerit选项多条命令的使用准备工作在容器内执行多条命令在Docker容器内部备份数据库并上传至远程存储场景描述示例代码-i选项-t选项-it组合选项示例用法结语Dockerit选项多条命令的使用在Docker中,dockercontainerexec命令可以在正在运行的容器内部......
  • 如何查看docker 项目的配置文件
    目录如何查看Docker项目的配置文件方法一:通过Docker命令查看配置文件方法二:通过数据卷挂载方式查看配置文件方法三:使用Docker可视化工具查看配置文件示例场景方法一:通过Docker命令查看配置文件方法二:通过数据卷挂载方式查看配置文件方法三:使用Docker可视化工具查看配......
  • 42. GameOver 及 Menu 面板
    本节目标实现GameOver面板,并且在点击返回菜单之后进入Menu场景,点击Menu场景中的NewGame进入游戏开始实现GameOver面板记得给BackToStartButton添加turnbutton样式添加GameOver对象当点击醒来按钮的时候,会调用GameOverPanel.BackToStart()方法,然后广播l......
  • docker-compose 部署apollo
    apollo-1.9.2docker-compose.yamlversion:'3'services:#模拟一个正常的mysql数据库mysql8:image:mysql:5.7restart:alwayscontainer_name:mysqlports:-3306:3306volumes:-./databases/mysql/logs:/var/log/mysql......
  • docker-compose 部署nacos
    version:'3'services:#模拟一个正常的mysql数据库mysql8:image:mysql:5.7restart:alwayscontainer_name:mysqlports:-3306:3306volumes:-./databases/mysql/logs:/var/log/mysql-./databases/mysql/data:/v......
  • Docker 实现类似花生壳动态域名解析
    前置条件准备工作  一,腾讯云注册的域名  二,运行Docker的服务器(我这使用的绿联云DX4600)  三,家用电信宽带,公网IP可以打客服电话申请  1.  首先申请个域名,各大云平台一般都有渠道,不备案也可以用,以下是腾讯云域名注册链接腾讯云官网 2.域名到手......
  • 全网最详细Docker命令(分类总结)
    默认存储容器地址cd/var/lib/docker容器生命周期Docker命令开启docker:systemctlstartdocker查看docker状态:systemctlstatusdocker停止:systemctlstopdocker重启:systemctlrestartdockerdocker开机自启:systemctlenabledocker镜像拉取镜像docker......
  • CF 1842 H
    给自己的博客引流:3.15解除密码这个是这篇中最认真写的题。CF1842H妙妙题!!!太牛了。首先,\(x_i\in[0,1]\),可以有两种:\(x_i<0.5,x_i\ge0.5\)。因为在\([0,1]\)中抽出\(0.5\)的几率为\(0\),就可以分成\(x_i<0.5,x_i>0.5\)。如果这样分,那么\(x_i,x_j<0.5\impliesx_i+x......
  • docker容器操作
    可以把镜像运行成容器,一个镜像可以运行出多个容器案例(把centos7运行成容器)#--name=centos7容器名#run:创建并运行#-di:创建出容器并运行,命令行还在宿主机dockerrun-di--name=centos7centos:centos7容器操作命令#查看正在运行的容器dockerps#查看所有容......