docker 数据盘映射方案

docker run -itd -v /data/:/data1 centos  bash // -v 用来指定挂载目录,

:前面的/data为本地目录,:后面的/data1 为容器里的目录:


docker:/root# docker run -itd --name zjtest8_frontend -v /data/zjtest8/frontend/:/var/www 192.168.32.150:5000/zjzc_centos6.5_m3 bash
e7ddb534ff695fe520e057a960e340b585658878096cbbc59562f582e4531f8f
docker:/root# docker ps
CONTAINER ID        IMAGE                                   COMMAND             CREATED             STATUS              PORTS               NAMES
e7ddb534ff69        192.168.32.150:5000/zjzc_centos6.5_m3   "bash"              3 seconds ago       Up 1 seconds                            zjtest8_frontend    
bc9914f15b3b        192.168.32.150:5000/zjzc_centos6.5_m3   "bash"              52 minutes ago      Up 42 minutes                           zjtest8_haproxy     
docker:/root# docker exec -it e7ddb534ff69 bash



把宿主机的/data/zjtest8/frontend/ 映射到容器的/var/www 目录


bash-4.1# df -h
Filesystem            Size  Used Avail Use% Mounted on
rootfs                9.8G  1.5G  7.8G  17% /
/dev/mapper/docker-253:0-131547-e7ddb534ff695fe520e057a960e340b585658878096cbbc59562f582e4531f8f
                      9.8G  1.5G  7.8G  17% /
tmpfs                 3.9G     0  3.9G   0% /dev
shm                    64M     0   64M   0% /dev/shm
/dev/mapper/vg00-lv_root
                      490G  4.9G  461G   2% /var/ww


1.haproxy: 192.168.32.152

docker run -itd -v /data/zjtest8/haproxy/:/var/log/haproxy/ --net=none --name zjtest8_haproxy   192.168.32.150:5000/zjzc_centos6.5_m3  bash



2.backoffice:192.168.32.153


docker run -itd --name zjtest8_backoffice -v /data/zjtest8/backoffice/:/var/www 192.168.32.150:5000/zjzc_centos6.5_m3 bash

3.frontend:192.168.32.154

docker run -itd --name zjtest8_frontend  -v /data/zjtest8/frontend/:/var/www 192.168.32.150:5000/zjzc_centos6.5_m3 bash


4.app:192.168.32.155

宿主机挂载t盘:
mount -t cifs //192.168.32.7/Public /t -o username=Administrator,password=Zjcap123,rw,dir_mode=0777,file_mode=0777

mkdir apache-tomcat-7.0.55_8081

mkdir apache-tomcat-7.0.55_8082

mkdir=apache-tomcat-7.0.55_8083

docker:/data/zjtest8# ls -ltr
total 24
drwxr-xr-x 2 root root 4096 Mar 22 16:39 haproxy
drwxr-xr-x 2 root root 4096 Mar 22 16:43 frontend
drwxr-xr-x 2 root root 4096 Mar 23 10:15 backoffice
drwxr-xr-x 2 root root 4096 Mar 23 10:33 apache-tomcat-7.0.55_8081
drwxr-xr-x 2 root root 4096 Mar 23 10:33 apache-tomcat-7.0.55_8082
drwxr-xr-x 2 root root 4096 Mar 23 10:33 apache-tomcat-7.0.55_8083

docker run -itd --name zjtest8_app --privileged -v /data/zjtest8/apache-tomcat-7.0.55_8081/:/usr/local/apache-tomcat-7.0.55_8081/  -v /data/zjtest8/apache-tomcat-7.0.55_8082/:/usr/local/apache-tomcat-7.0.55_8082/    -v /data/zjtest8/apache-tomcat-7.0.55_8083/:/usr/local/apache-tomcat-7.0.55_8083/  -v /t:/t  -v /data/zjtest8/nfs01/:/nfs01  192.168.32.150:5000/zjzc_centos6.5_app  bash


5.nfs01 服务器: 192.168.32.156


docker run -itd --name --privileged zjtest8_nfs01  -v /data/zjtest8/nfs01/:/nfs01 192.168.32.150:5000/zjzc_centos6.5_m4 bash



6.redis 服务器:192.168.32.157


docker run -itd --name zjtest8_redis01  -v /data/zjtest8/redis01/:/data01 192.168.32.150:5000/zjzc_centos6.5_m4 bash


7. zjzc mysql 服务器:192.168.32.158

docker run -itd --name zjtest8_zjzc_mysql -v /data/zjtest8/zjzc_mysql/:/data01 192.168.32.150:5000/zjzc_centos6.5_m4 bash


8.pay mysql 数据库:192.168.32.159

docker run -itd --name zjtest8_pay_mysql -v /data/zjtest8/pay_mysql/:/data01 192.168.32.150:5000/zjzc_centos6.5_m4 bash



docker run -itd --name zjtest8_nfs01 --privileged  -v /data/zjtest8/nfs01/:/nfs01 192.168.32.150:5000/zjzc_centos6.5_m4 bash





--privileged=false         Give extended privileges to this container
...
大约在0.6版,privileged被引入docker。
使用该参数,container内的root拥有真正的root权限。
否则,container内的root只是外部的一个普通用户权限。
privileged启动的容器,可以看到很多host上的设备,并且可以执行mount。
甚至允许你在docker容器中启动docker容器。




转载于:https://www.cnblogs.com/zhaoyangjian724/p/6200138.html

你可能感兴趣的:(docker 数据盘映射方案)