linux怎么查看本机内存大小
237
2022-10-30
Docker系列14:容器编排(2)
三、容器编排实战
案例1
第一步:创建yml文件
[root@host1 ~]# vim docker-compose.yml version: '3' services: web: image: nginx:latest ports: - "5000:5000" links: - redis redis: image: redis
第二步:启动容器
[root@host1 ~]# docker-compose up -d
第三步:查看通过compose启动进程的状态
[root@host1 ~]# docker-compose ps Name Command State Ports ---------------------------------------------------------------------------------------------------------------------------- root_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp root_web_1 nginx -g daemon off; Up 0.0.0.0:5000->5000/tcp, 80/tcp
第四步:查看日志信息
[root@host1 ~]# docker-compose logs
第五步:关闭服务
[root@host1 ~]# docker-compose down Stopping root_web_1 ... done Stopping root_redis_1 ... done Removing root_web_1 ... done Removing root_redis_1 ... done Removing network root_default
案例2
第一步:创建Dockerfile文件
[root@host1 ~]# vim Dockerfile #Nginx #Version 1.0.1 #Author zxhk #Base image FROM centos:7 #Maintainer MAINTAINER zxhk08@qq.com #Commands RUN rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm RUN yum install -y nginx RUN echo "daemon off;" >> /etc/nginx/nginx.conf EXPOSE 80 CMD ["nginx"]
第二步:执行Dockerfile文件
[root@host1 ~]# docker build -t newweb/nginx:v1-1 ./
第三步:构建docker-compose.yml
[root@host1 ~]# vim docker-compose.yml version: '2' services: web1: image: newweb/nginx:v1.0.1 volumes: - /data/www1:/usr/share/nginx/html ports: - "8080:80" web2: image: newweb/nginx:v1.0.1 volumes: - /data/www2:/usr/share/nginx/html ports: - "8081:80" web3: image: newweb/nginx:v1.0.1 volumes: - /data/www3:/usr/share/nginx/html ports: - "8082:80"
第四步:开始构建
[root@host1 ~]# docker-compose up -d
第五步:查看通过compose启动进程的状态
[root@host1 ~]# docker-compose ps
第六步:查看日志信息
[root@host1 ~]# docker-compose logs
第七步:关闭服务
[root@host1 ~]# docker-compose down
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~