centos安装docker-compose

it2024-08-13  38

git地址:https://github.com/docker/compose/releases/

找到需要安装的版本 curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose 加执行权限 chmod +x /usr/local/bin/docker-compose

docker-compose怎么启动的容器: 直接使用docker-compose读取yml配置就可以启动容器了

docker-compose -f 指定dockercompose文件 up 或者 docker-compose up -d (后台运行) 读取当前路径下的docker-compose.yaml

docker-compose 中加. build 会打包当前目录下的dockerfile,或docker. bulid先打包dockerfile镜像

version: "3" services: mysql: # 镜像:版本 image: mysql:5.7 # 给容器宿主机权限 privileged: true # 端口: 容器外:容器内 ports: - 3306:3306 # 执行命令 command: - --character-set-server=utf8mb4 - --collation-server=utf8mb4_unicode_ci - --skip-character-set-client-handshake - --default-time-zone=SYSTEM - --log-timestamps=SYSTEM - --max-connections=10240 # 环境变量 environment: MYSQL_ROOT_PASSWORD: passwd TZ: Asia/Shanghai # 将宿主机文件挂载到容器中 volumes: - ./sql:/docker-entrypoint-initdb.d # 重启 restart: always redis: image: redis:alpine ports: - 6379:6379 environment: - TZ=Asia/Shanghai nsqlookupd: image: nsqio/nsq command: /nsqlookupd ports: - 4160:4160 - 4161:4161 nsqd: image: nsqio/nsq command: /nsqd --lookupd-tcp-address=nsqlookupd:4160 depends_on: - nsqlookupd ports: - 4150:4150 - 4151:4151 nsqadmin: image: nsqio/nsq command: /nsqadmin --lookupd-http-address=nsqlookupd:4161 depends_on: - nsqlookupd ports: - 4171:4171

docker-compose 默认生成的容器名为:

当前文件名_servicename_1 Starting pms_mysql_1

docker-compose源码地址:

https://github.com/docker/compose
最新回复(0)