docker compose部署
2020-11-09 23:37
1196 查看
docker compose部署
————资源控制 [root@localhost ~]# docker network ls NETWORK ID NAME DRIVER SCOPE 4946cb00240c bridge bridge local 7ad0dfddaa0f host host local 906f0be0af7c none null local #自定义网络固定IP docker network create --subnet=172.18.0.0/24 mynetwork [root@localhost ~]# ifconfig br-b51371ede3af: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.18.0.1 netmask 255.255.255.0 broadcast 172.18.0.255 ether 02:42:d7:6a:3d:f3 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost ~]# docker run -itd --name test1 --net mynetwork --ip 172.18.0.100 centos:7 /bin/bash [root@localhost ~]# docker network ls NETWORK ID NAME DRIVER SCOPE 4946cb00240c bridge bridge local 7ad0dfddaa0f host host local b51371ede3af mynetwork bridge local 906f0be0af7c none null local [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 47132f608de0 centos:7 "/bin/bash" About a minute ago Up About a minute test1 [root@localhost ~]# docker exec -it 47132f608de0 /bin/bash [root@47132f608de0 /]# yum install net-tools -y [root@47132f608de0 /]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.18.0.100 netmask 255.255.255.0 broadcast 172.18.0.255 ether 02:42:ac:12:00:64 txqueuelen 0 (Ethernet) RX packets 6968 bytes 12136790 (11.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4113 bytes 225662 (220.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ——————compose部署 #环境部署所有主机安装docker环境(内容为docker基础) yum install docker-ce -y #下载compose [root@localhost ~]# cp -p docker-compose /usr/local/bin/ [root@localhost ~]# chmod +x /usr/local/bin/docker-compose [root@localhost ~]# mkdir compose_nginx [root@localhost ~]# cd compose_nginx/ [root@localhost compose_nginx]# mkdir nginx [root@localhost compose_nginx]# cd nginx/ [root@localhost nginx]# vim Dockfile [root@localhost nginx]# vim run.sh [root@localhost nginx]# rz -E rz waiting to receive. [root@localhost nginx]# ls Dockerfile nginx-1.12.0.tar.gz run.sh [root@localhost nginx]# cd .. [root@localhost compose_nginx]# ls nginx [root@localhost compose_nginx]# vim docker-compose.yml version: '3' services: nginx: hostname: nginx build: context: ./nginx dockerfile: Dockerfile ports: - 1216:80 - 1217:443 networks: - yun volumes: - ./wwwroot:/usr/local/nginx/html networks: yun: [root@localhost compose_nginx]# ls docker-compose.yml nginx [root@localhost compose_nginx]# docker-compose -f docker-compose.yml up -d ls cd wwwroot vim index.html <h1>this is kevin web</h1> yum install tree -y [root@localhost compose_nginx]# tree ./ ./ ├── docker-compose.yml ├── nginx │ ├── Dockerfile │ ├── nginx-1.12.0.tar.gz │ └── run.sh └── wwwroot └── index.html [root@localhost compose_nginx]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a5a6c6da883d compose_nginx_nginx "/run.sh" 3 minutes ago Up 3 minutes 0.0.0.0:1216->80/tcp, 0.0.0.0:1217->443/tcp compose_nginx_nginx_1 47132f608de0 centos:7 "/bin/bash" 43 minutes ago Up 43 minutes test1 [root@localhost compose_nginx]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE compose_nginx_nginx latest 502db66e6ec9 3 minutes ago 516MB centos 7 7e6257c9f8d8 6 weeks ago 203MB iptables -F setenforce 0 ————————tomcat version: '3' services: nginx: hostname: nginx build: context: ./nginx dockerfile: Dockerfile ports: - 1216:80 - 1217:443 networks: - yun volumes: - ./wwwroot:/usr/local/nginx/html tomcat: hostname: tomcat build: context: ./tomcat dockerfile: Dockerfile ports: - 1234:8080 networks: - hu networks: yun: hu:
相关文章推荐
- Dockerfile 撰写
- Dockerfile 创建
- Docker安装优化与Docker基础命令
- Docker安装RabbitMQ
- Docker学习—DockerFile
- Docker知识进阶与容器编排技术
- Ubuntu 20.04 Docker 安装并配置
- Docker Dockerfile
- Docker思维导图汇总
- 基于Docker的Mysql主从复制搭建
- 【Azure DevOps系列】Azure DevOps使用Docker将.NET应用程序部署在云服务器
- 记一次k8s修改docker存储路径引发的问题
- 10 个冷门但又非常实用的 Docker 使用技巧
- docker私有仓库链接信任log日志清除
- 【Azure DevOps系列】如何在Azure DevOps上构建Docker镜像(一)
- SpringBoot打包成Docker镜像
- Ubuntu16.04 Server版的docker离线及nvidia-docker安装
- CentOS 安装 Docker 报错及解决过程
- MySQL系列:Docker安装 MySQL提示错误:Access denied for user'root'@'localhost' (using password:yes)
- Docker快速部署开源无agent的自动化运维平台spug