Dockerfile 經常使用指令php
Build鏡像命令html
構建PHP網站環境鏡像python
構建Java網站環境鏡像mysql
一 Dockerfile 經常使用指令:nginx
這裏咱們使用Dockerfile 自定製鏡像的操做步驟以下:sql
格式:docker
Usage: docker build [OPTIONS] PATH | URL | - [flags]centos
-t ,--tag list 生成鏡像的名稱網絡
-f ,--file string 指定Dockerfile文件的位置app
好比:
FROM centos:laster MAINTAINER bigbao RUN yum -y install nginx COPY run.sh /data/package EXPOSE 80 CMD ["run.sh"]
docker build -t shykes/myapp01 -f path/Dockerfile_01test /path
最後一個path的做用是在宿主機的什麼位置執行,由於裏面有COPY文件,因此得指定相對路徑
就像咱們以前有建立一個博客系統,咱們的簡要步驟以下:
0、建立數據卷
docker volume create mysql_volume
一、建立一個多容器共同的網絡通道
docker network create lnmp_net
二、建立MySQL容器
docker run -d \
--name lnmp_mysql \
--net lnmp \
--mount src=mysql_volume,dst=/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 -e MYSQL_DATABASE=wordpress mysql:5.7 --character-set-server=utf8
三、建立PHP容器
docker run -d --name lnmp_php --net lnmp_net --mount src=wwwroot,dst=/wwwroot php:v1
四、牀架Nginx容器
docker run -d --name lnmp_nginx --net lnmp_net -p 8800:80 --mount type=bind,src=/data/nginx/nginx.conf,dst=/usr/local/nginx/conf/nginx.conf --mount src=wwwroot,dst=/wwwroot nginx:v1.15
五、把wordpress博客啓動起來
https://cn.wordpress.org/wordpress-4.9.4-zhCN.tar.
博客總結來源於:http://edu.51cto.com/course/10659.html