docker-compose能干啥
- docker-compose 是 docker 官方提供的容器编排工具,可以实现对Docker容器集群的快速编排。
- 相关的容器编排工具:Kubernetes
- 什么是容器编排工具?
容器编排工具提供调度和集群的技术,提供用于基于容器应用可扩展性的基本机制。这些工具使用容器服务,并编排他们以决定容器之间如何进行交互。此外,编排允许容器可以存在并执行在集群上,这使得他们能够扩展来适应增加的处理负荷。
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的进程:
网友评论