一、准备:一个纯净的centos6.9系统
[root@docker02 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
kod v1 a213e5f1a088 19 minutes ago 642MB
centos6.9_nginx_ssh_v2 latest b58987f2b788 About an hour ago 589MB
centos6.9_nginx_ssh_v1 latest 259e3ab53ca3 About an hour ago 589MB
centos6.9_nginx_v1 latest 68b05ad83c80 2 hours ago 460MB
nginx latest 9beeba249f3e 11 days ago 127MB
alpine latest b7b28af77ffe 10 months ago 5.58MB
centos 6.9 adf829198a7f 21 months ago 195MB
gcr.io/google_containers/kubedns-amd64 1.9 26cf1ed9b144 3 years ago 47MB
gcr.io/google_containers/dnsmasq-metrics-amd64 1.0 5271aabced07 3 years ago 14MB
gcr.io/google_containers/kube-dnsmasq-amd64 1.4 3ec65756a89b 3 years ago 5.13MB
gcr.io/google_containers/exechealthz-amd64 1.2 93a43bfb39bf 3 years ago 8.37MB
二、启动一个基础环境的容器
[root@docker02 ~]# docker run -it -p 80:80 centos /bin/bash
三、安装nginx、php服务及依赖
[root@105026ea275a ~]# yum install nginx php-fpm php-gd php-mbstring -y
四、修改php配置文件
[root@105026ea275a ~]# cat /etc/php-fpm.d/www.conf
user = nginx
group = nginx
五、编写nginx配置文件
[root@105026ea275a ~]# cat /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
root /code;
location / {
index index.php index.html index.htm;
}
六、将网站代码信息cp到容器中
[root@docker02 ~]# docker cp kodexplorer4.40.zip 105026ea275a:/code
七、在容器中安装unzip命令,并解压代码
[root@105026ea275a code]# unzip kodexplorer4.40.zip
八、网站代码目录授权
[root@105026ea275a code]# chown -R nginx.nginx /code
九、编写容器初始化脚本,为了容器能夯住
[root@105026ea275a code]# vi /init.sh
#!/bin/bash
service php-fpm start
nginx -g 'daemon off;'
十、将制作好的容器提交为镜像
[root@docker02 ~]# docker commit 10cebe4283c2 kod:v1
十一、启动制作的可道云网站镜像
[root@docker02 ~]# docker run -d -p 888:80 kod:v1 /bin/bash /init.sh
十二、网页检查效果

0 Comments