制作可道云镜像
vim dockerfile
FROM centos:6.9
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo && \
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo && \
yum install nginx -y && \
yum install php-fpm -y && \
yum install php-mbstring -y && \
yum install php-gd -y && \
yum clean all
ADD nginx.conf /etc/nginx/nginx.conf
ADD kod.tar.gz /usr/share/nginx/html
ADD init.sh /init.sh
CMD ["/bin/bash","/init.sh"]
查看ADD的配置文件和需要推送的目录脚本
cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php index.html ;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
~
查看脚本为了保证容器正常启动并夯住
cat init.sh
#!/bin/bash
sed -i '/user =/,/group =/s#apache#nginx#g' /etc/php-fpm.d/www.conf
chown -R nginx.nginx /usr/share/nginx/html
/etc/init.d/php-fpm start
/etc/init.d/nginx start
tail -f /etc/hosts
创建并启动
docker build -t nginx:v1 .
docker run -d -p 80:80 nginx:v1