[root@localhost ~]
# mkdir nginx
[root@localhost ~]
# cd nginx/
[root@localhost nginx]
# touch dockerfile
[root@localhost nginx]
# vim dockerfile
from daocloud.io/library/centos:7
maintainer nginx
run yum install -y epel-release
run yum install -y gcc gcc-c++ pcre pcre-devel openssl openssl-devel zlib zlib-server make
run useradd -s /sbin/nologin -m nginx
add nginx-1.16.0.tar.gz /usr/local/
workdir /usr/local/nginx-1.16.0/
run ./configure --prefix=/usr/local/nginx --group=nginx --user=nginx
run make
&&make
install
run mkdir /tmp/nginx
expose 80
cmd /bin/sh -c 'nginx -g "daemon off;"'
[root@localhost nginx]
# ls
dockerfile nginx-1.16.0.tar.gz
[root@localhost nginx]
# docker build -t nginx:v1 .
docker 容器啟動時,缺省會把容器內部第乙個程序,也就是pid=1的程式,作為docker容器是否正在執行的依據,如果 docker 容器pid=1的程序掛了,那麼docker容器便會直接退出。
使用dockerfile安裝nginx時
需要執行daemon off命令。放置前台啟動
nginx預設是以後臺模式啟動的,docker未執行自定義的cmd之前,nginx的pid是1,執行到cmd之後,nginx就在後台執行,bash或sh指令碼的pid變成了1。所以一旦執行完自定義cmd,nginx容器也就退出了。為了保持nginx的容器不退出,應該關閉nginx後台執行
編譯Dockerfile得到映象
建立dockerfile,配置基礎映象,和需要安裝的依賴。from python 3.7 run python m pip install i upgrade numpy 1.19.2 waitress 1.4.4 flask 1.1.2 workdir temper env lang c.utf ...
dockerfile 安裝啟動nginx php
from centos latest maintainer env time zome asia shanghai arg wj nginx 1.15.7 wget copy nginx.conf usr local nginx add wj.tar.gz tmp run yum y install...
Linux 利用nginx原始碼編譯安裝nginx
1,centos 7 2,nginx 1.13.6 1,編譯前準備 yum install pcre openssl openssl devel zlib zlib develcd usr local src wget 6.tar gz3,解壓nginx原始碼 tar xzvf nginx 1.13...