久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

Docker安裝Nginx的方法是什么-創(chuàng)新互聯(lián)

這篇文章給大家介紹Docker安裝Nginx的方法是什么,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

博野ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書(shū)未來(lái)市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書(shū)銷(xiāo)售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書(shū)合作)期待與您的合作!


方法一、通過(guò) Dockerfile構(gòu)建
創(chuàng)建Dockerfile
首先,創(chuàng)建目錄nginx,用于存放后面的相關(guān)東西。
[root@huixuan ~]# mkdir -p ~/nginx/www ~/nginx/logs ~/nginx/conf
[root@huixuan ~]# ls
anaconda-ks.cfg  Dockerfile  nginx  vpd.properties
[root@huixuan ~]# 


www目錄將映射為nginx容器配置的虛擬目錄
logs目錄將映射為nginx容器的日志目錄
conf目錄里的配置文件將映射為nginx容器的配置文件
進(jìn)入創(chuàng)建的nginx目錄,創(chuàng)建Dockerfile


[root@huixuan nginx]# cat Dockerfile 
FROM debian:jessie


MAINTAINER NGINX Docker Maintainers "docker-maint@nginx.com"


ENV NGINX_VERSION 1.10.1-1~jessie


RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \
        && echo "deb http://nginx.org/packages/debian/ jessie nginx" >> /etc/apt/sources.list \
        && apt-get update \
        && apt-get install --no-install-recommends --no-install-suggests -y \
                                                ca-certificates \
                                                nginx=${NGINX_VERSION} \
                                                nginx-module-xslt \
                                                nginx-module-geoip \
                                                nginx-module-image-filter \
                                                nginx-module-perl \
                                                nginx-module-njs \
                                                gettext-base \
        && rm -rf /var/lib/apt/lists/*


# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
        && ln -sf /dev/stderr /var/log/nginx/error.log


EXPOSE 80 443


CMD ["nginx", "-g", "daemon off;"]
[root@huixuan nginx]# 


通過(guò)Dockerfile創(chuàng)建一個(gè)鏡像,替換成你自己的名字
[root@huixuan nginx]# docker build -t nginx .
Sending build context to Docker daemon 4.608 kB
Step 1/7 : FROM debian:jessie
Trying to pull repository docker.io/library/debian ... 
jessie: Pulling from docker.io/library/debian
3d77ce4481b1: Pull complete 
Digest: sha256:f29d0c98d94d6b2169c740d498091a9a8545fabfa37f2072b43a4361c10064fc
Status: Downloaded newer image for docker.io/debian:jessie
 ---> 4eb8376dc2a3
Step 2/7 : MAINTAINER NGINX Docker Maintainers "docker-maint@nginx.com"
 ---> Running in 805eb7f2e4e8
 ---> 1c1e36615d27
Removing intermediate container 805eb7f2e4e8
Step 3/7 : ENV NGINX_VERSION 1.10.1-1~jessie
 ---> Running in d86befe384a8
 ---> f559945b9860
Removing intermediate container d86befe384a8
Step 4/7 : RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62         && echo "deb http://nginx.org/packages/debian/ jessie nginx" >> /etc/apt/sources.list         && apt-get update         && apt-get install --no-install-recommends --no-install-suggests -y                                                 ca-certificates                                                 nginx=${NGINX_VERSION}                                                 nginx-module-xslt                                                 nginx-module-geoip                                                 nginx-module-image-filter                                                 nginx-module-perl                                                 nginx-module-njs                                                 gettext-base         && rm -rf /var/lib/apt/lists/*
 ---> Running in 273e2e414e8f


Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.AEdkYzmRAy --no-auto-check-trustdb --trust-model always --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-security-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-stable.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-security-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-stable.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-wheezy-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-wheezy-stable.gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
gpg: requesting key 7BD9BF62 from hkp server pgp.mit.edu
gpg: key 7BD9BF62: public key "nginx signing key <signing-key@nginx.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
Get:1 http://nginx.org jessie InRelease [2856 B]
Ign http://deb.debian.org jessie InRelease
Get:2 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:3 http://security.debian.org jessie/updates InRelease [94.4 kB]
Get:4 http://nginx.org jessie/nginx amd64 Packages [12.6 kB]
Get:5 http://security.debian.org jessie/updates/main amd64 Packages [647 kB]
Get:6 http://deb.debian.org jessie Release.gpg [2434 B]
Get:7 http://deb.debian.org jessie-updates/main amd64 Packages [23.1 kB]
Get:8 http://deb.debian.org jessie Release [148 kB]
Get:9 http://deb.debian.org jessie/main amd64 Packages [9064 kB]
Fetched 10.1 MB in 1min 53s (89.3 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:


The following packages have unmet dependencies:
 nginx-module-geoip : Depends: nginx (= 1.14.0-1~jessie)
 nginx-module-image-filter : Depends: nginx (= 1.14.0-1~jessie)
 nginx-module-njs : Depends: nginx (= 1.14.0-1~jessie)
 nginx-module-perl : Depends: nginx (= 1.14.0-1~jessie)
 nginx-module-xslt : Depends: nginx (= 1.14.0-1~jessie)
E: Unable to correct problems, you have held broken packages.
The command '/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62         && echo "deb http://nginx.org/packages/debian/ jessie nginx" >> /etc/apt/sources.list         && apt-get update         && apt-get install --no-install-recommends --no-install-suggests -y                                                 ca-certificates                                                 nginx=${NGINX_VERSION}                                                 nginx-module-xslt                                                 nginx-module-geoip                                                 nginx-module-image-filter                                                 nginx-module-perl                                                 nginx-module-njs                                                 gettext-base         && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100
[root@huixuan nginx]# 








創(chuàng)建完成后,我們可以在本地的鏡像列表里查找到剛剛創(chuàng)建的鏡像
方法一本人沒(méi)有創(chuàng)建成功。








方法二、docker pull nginx
查找Docker Hub上的nginx鏡像
[root@huixuan nginx]# docker search nginx


這里我們拉取官方的鏡像




等待下載完成后,我們就可以在本地鏡像列表里查到REPOSITORY為nginx的鏡像。
[root@huixuan nginx]# docker pull nginx
Using default tag: latest
Trying to pull repository docker.io/library/nginx ... 
latest: Pulling from docker.io/library/nginx
f2aa67a397c4: Pull complete 
3c091c23e29d: Pull complete 
4a99993b8636: Pull complete 
Digest: sha256:0edf702c890e9518b95b2da01286509cd437eb994b8d22460e40d72f6b79be49
Status: Downloaded newer image for docker.io/nginx:latest
[root@huixuan nginx]# 




使用nginx鏡像
運(yùn)行容器


[root@huixuan nginx]# docker run -p 80:80 --name mynginx -v $PWD/www:/www -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/wwwlogs  -d nginx 
c782a8c09f261929ef26fe5cbcebc85dd9dda76c97475878f77b8a2ad3faa175
/usr/bin/docker-current: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:364: container init caused \"rootfs_linux.go:54: mounting \\\"/root/nginx/conf/nginx.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/a573557a07d294822e22c1a260a9531ba8e77a53a392d16dc9bdddfaf7147398/merged\\\" at \\\"/var/lib/docker/overlay2/a573557a07d294822e22c1a260a9531ba8e77a53a392d16dc9bdddfaf7147398/merged/etc/nginx/nginx.conf\\\" caused \\\"not a directory\\\"\""
: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
[root@huixuan nginx]# 


通過(guò)下面的命令啟動(dòng)
[root@huixuan nginx]# docker run -p 80:80 --name mynginx1111 -d nginx 
e5f669143490eb6dd86816da584c375d17f9ca137b8d061e9251536f7172233d
[root@huixuan nginx]# 






命令說(shuō)明:
-p 80:80:將容器的80端口映射到主機(jī)的80端口
--name mynginx:將容器命名為mynginx
-v $PWD/www:/www:將主機(jī)中當(dāng)前目錄下的www掛載到容器的/www
-v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf:將主機(jī)中當(dāng)前目錄下的nginx.conf掛載到容器的/etc/nginx/nginx.conf
-v $PWD/logs:/wwwlogs:將主機(jī)中當(dāng)前目錄下的logs掛載到容器的/wwwlogs
查看容器啟動(dòng)情況




[root@huixuan nginx]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
e5f669143490        nginx               "nginx -g 'daemon ..."   37 seconds ago      Up 36 seconds       0.0.0.0:80->80/tcp   mynginx1111
[root@huixuan nginx]# 


通過(guò)瀏覽器訪問(wèn)

Docker安裝Nginx的方法是什么

關(guān)于Docker安裝Nginx的方法是什么就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。

本文標(biāo)題:Docker安裝Nginx的方法是什么-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://sd-ha.com/article38/dohhsp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)公司、搜索引擎優(yōu)化、微信小程序、軟件開(kāi)發(fā)、微信公眾號(hào)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都app開(kāi)發(fā)公司