1. 程式人生 > >docker 資料對映方案

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