Consul是HashiCorp公司推出的开源工具,用于实现分布式系统的服务发现与配置;
●支持健康检查,允许存储键值对;
●基于Golong语言,可移植性强;
●支持ACL访问控制;
与Docker等轻量级容器可无缝配合。
Docker Compose的前身是Fig,它是一个定义及运行多个Docker容器的工具;
使用Docker Compose不再需要使用Shell脚本来启动容器;
Docker Compose非常适合组合使用多个容器进行开发的场景;
Consul是HashiCorp公司推出的开源工具,用于实现分布式系统的服务发现与配置
提示:以下是本篇文章正文内容,下面案例仅可供参考
build dockerfile context 指定Dockerfile文件名构建镜像上下文路径
image 指定镜像
command 执行命令,覆盖默认命令
container name 指定容器名称,由于容器名称是唯一的,如果指定自定 义名称,则无法scale
deploy 指定部署和运行服务相关配置,只能在Swarm模式使用
environment 添加环境变量
networks 加入网络
ports 暴露容器端口,与-p相同,但端口不能低于60
volumes 挂载宿主机路径或命令卷
restart 重启策略,默认no,always,no-failure,unless-stoped
hostname 容器主机名
build 重新构建服务
ps 列出容器
up 创建和启动容器
exec 在容器里面执行命令
scale 指定一个服务容器的启动数量
top 显示容器进程3=
logs 查看容器输出
down 删除容器、网络、数据卷(彻底删除)
stop/start/restart/ 停止/启动/重启服务
//环境部署所有主机安装docker环境(内容为docker基础)
yum install docker-ce -y
//下载compose(上传docker_compose)
curl -L https://github.com/docker/compose/releases/download/1.21.1/docker-compose-uname -s
-uname -m
-o /usr/local/bin/docker-compose
cp -p docker-compose /usr/local/bin/
chmod +x /usr/local/bin/docker-compose
mkdir /root/compose_nginx
[root@docker ~]# rz -E
rz waiting to receive.
[root@docker ~]# ls
anaconda-ks.cfg docker-compose initial-setup-ks.cfg
[root@docker ~]# chmod +x docker-compose
[root@docker ~]# ls
anaconda-ks.cfg docker-compose initial-setup-ks.cfg
[root@docker ~]# mv docker-compose /usr/local/bin
[root@docker ~]# mkdir /root/compose_nginx
[root@docker ~]# cd compose_nginx/
[root@docker compose_nginx]# ls
[root@docker compose_nginx]# pwd
/root/compose_nginx
vim /root/compose_nginx/docker-compose.yml
version: ‘3’
services:
nginx:
hostname: nginx
build:
context: ./nginx
dockerfile: Dockerfile
ports:
- 1216:80
- 1217:443
networks:
- cluster
volumes:
- ./wwwroot:/usr/local/nginx/html
networks:
cluster:
[root@docker compose_nginx]# vim docker-compose.yml
version: '3'
services:
nginx:
hostname: nginx
build:
context: ./nginx
dockerfile: Dockerfile
ports:
- 1216:80
- 1217:443
networks:
- cluster
volumes:
- ./wwwroot:/usr/local/nginx/html
networks:
cluster:
vim dockerfile
FROM centos:7 as build
ADD nginx-1.15.9.tar.gz /mnt
WORKDIR /mnt/nginx-1.15.9
RUN yum install -y gcc pcre pcre-devel devel zlib-devel make &> /dev/null && \
yum clean all &&\
sed -i 's/CFLAGS="$CFLAGS -g"/#CFLAGS="$CFLAGS -g"/g' auto/cc/gcc && \
./configure --prefix=/usr/local/nginx &> /dev/null && \
make &>/dev/null && \
make install &>/dev/null && \
rm -rf /mnt/nginx-1.15.9
FROM centos:7
EXPOSE 80
VOLUME ["/usr/local/nginx/html"]
COPY --from=build /usr/local/nginx /usr/local/nginx
CMD ["/usr/local/nginx/sbin/nginx","-g","daemon off;"]
docker-compose -f docker-compose.yml up -d
[root@docker compose_nginx]# echo "this is a container nginx" >> wwwroot/index.html
[root@docker compose_nginx]# tree ./
./
├── docker-compose.yml
├── nginx
│ ├── dockerfile
│ └── nginx-1.15.9.tar.gz
└── wwwroot
└── index.html
2 directories, 4 files
[root@consul compose_nginx]# docker-compose -f docker-compose.yml up -d
[root@docker compose_nginx]# docker-compose -f docker-compose.yml up -dCreating network "compose_nginx_cluster" with the default driver
Building nginx
Step 1/9 : FROM centos:7 as build
---
Successfully built 921483a5da3b
Successfully tagged compose_nginx_nginx:latest
WARNING: Image for service nginx was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating compose_nginx_nginx_1 ... done
[root@docker compose_nginx]# docker-compose ps
Name Command State Ports
-----------------------------------------------------------------------
compose_nginx_nginx /usr/local/nginx/sb Up 0.0.0.0:1217->443/t
_1 in/ngin ... cp,:::1217->443/tcp
, 0.0.0.0:1216->80/
tcp,:::1216->80/tc
tomcat:
hostname: tomcat
build:
context: ./tomcat
dockerfile: Dockerfile
ports:
8080: 8080
networks:
- mynengyuan
volumes:
- ./data/:/usr/local/tomcat/
[root@docker compose_nginx]# docker-compose -f docker-compose.yml up -d
docker 基础 *** 作/常规 *** 作
1、image 容器的管理命令
2、dockerfile
3、docker 网络
4、docker 私有仓库
registry
harbor
docker-compose ——>资源编排和管理手段 (docker swarm && k8s )
三consul部署代码如下(示例):
data = pd.read_csv(
'https://labfile.oss.aliyuncs.com/courses/1283/adult.data.csv')
print(data.head())
该处使用的url网络请求的数据。
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)