docker

docker-compose

2022-07-27  本文已影响0人  sunpy

docker-compose能干啥


docker-compose安装


[root@ecs-140051 sunpy-docker]# curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   423  100   423    0     0    538      0 --:--:-- --:--:-- --:--:--   538
100 16.2M  100 16.2M    0     0  9552k      0  0:00:01  0:00:01 --:--:-- 1136k
[root@ecs-140051 sunpy-docker]# docker-compose -version
-bash: /usr/local/bin/docker-compose: Permission denied
[root@ecs-140051 sunpy-docker]# sudo chmod +x /usr/local/bin/docker-compose
[root@ecs-140051 sunpy-docker]# docker-compose -version
docker-compose version 1.25.1, build a82fef07

docker-compose安装mysql


编写yml文件:

version: "3"
services:
  mysql:
    image: mysql:latest
    restart: always
    container_name: mysql
    ports:
      - 3389:3306
    volumes:
      - /data/software/mysql/conf/:/etc/mysql/conf.d
      - /data/software/mysql/data:/var/lib/mysql
      - /data/software/mysql/log/:/var/log/mysql
    environment:
      MYSQL_ROOT_PASSWORD: xxxxx
      MYSQL_DATABASE: xxxxx
      MYSQL_USER: xxxxx
      MYSQL_PASSWORD: xxxxx

启动mysql容器,执行:docker-compose -f mysql.yml up -d

[root@ecs-140051 docker-compose]# docker-compose -f mysql.yml up -d
Creating network "docker-compose_default" with the default driver
Creating mysql ... done

关闭mysql容器:

docker-compose -f mysql.yml down
查看docker容器内mysql的进程:

参考


https://xie.infoq.cn/article/8bb8f0a775cae4f2e20b305c7

上一篇下一篇

猜你喜欢

热点阅读