人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動(dòng)態(tài)

Docker容器簡(jiǎn)單部署nginx過(guò)程解析

發(fā)布日期:2022-01-31 11:29 | 文章來(lái)源:源碼之家

1、容器中部署nginx服務(wù)

centos:7鏡像運(yùn)行一個(gè)容器,并且,在這個(gè)容器內(nèi)部署Nginx服務(wù)。

[root@Docker ~]# docker pull centos:7 //下載鏡像
[root@Docker ~]# docker run -itd --name webapp --restart=always centos:7 //運(yùn)行一個(gè)容器名為:webapp
[root@Docker ~]# docker cp nginx-1.16.0.tar.gz webapp:/root //將本地nginx包導(dǎo)入webapp容器內(nèi)
[root@Docker ~]# docker exec -it webapp /bin/bash //進(jìn)入容器
[root@85099880dabe ~]# tar zxf nginx-1.16.0.tar.gz
[root@85099880dabe ~]# cd nginx-1.16.0
[root@85099880dabe nginx-1.16.0]# yum install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel //下載相關(guān)依賴(lài)包
[root@85099880dabe nginx-1.16.0]# useradd -M -s /sbin/nologin nginx //添加一個(gè)沒(méi)有登錄權(quán)限的nginx用戶(hù)
[root@85099880dabe nginx-1.16.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx //編譯安裝

[root@85099880dabe nginx-1.16.0]# make && make install //編譯安裝
[root@85099880dabe nginx-1.16.0]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/ //創(chuàng)建軟鏈接
[root@85099880dabe nginx-1.16.0]# nginx
[root@85099880dabe nginx-1.16.0]# nginx //確認(rèn)nginx服務(wù)開(kāi)啟
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
[root@85099880dabe nginx-1.16.0]# cd /usr/local/nginx/html/
[root@85099880dabe html]# echo "TEST WEB" > index.html
[root@85099880dabe html]# curl 127.0.0.1
TEST WEB

2、遷移鏡像

所需環(huán)境:

docker1主機(jī):192.168.45.129

docker2主機(jī):192.168.45.134

1)docker1主機(jī)

將docker1的剛剛創(chuàng)建的容器并制作成鏡像導(dǎo)入docker2主機(jī)上

[root@Docker ~]# docker commit webapp myweb //將webapp容器制作成鏡像名為myweb
sha256:b035b8e8a36140e1bdbda9cf3a736b139ea8a48db7871a10f509b8f34d4c0f82
[root@Docker ~]# docker save > myweb.tar myweb:latest //將鏡像導(dǎo)出
[root@Docker ~]# scp myweb.tar 192.168.45.134:/root //將鏡像導(dǎo)出的tar包c(diǎn)p給docker2主機(jī)
The authenticity of host '192.168.45.134 (192.168.45.134)' can't be established.
ECDSA key fingerprint is d7:77:71:90:34:25:c0:ec:e0:b6:5c:cc:6b:44:93:7b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.45.134' (ECDSA) to the list of known hosts.
root@192.168.45.134's password: //密碼為docker2主機(jī)的密碼
myweb.tar 100% 353MB 176.4MB/s 00:02

2)docker2主機(jī)

[root@Docker2 ~]# docker load < myweb.tar //將剛剛cp過(guò)來(lái)的tar包制作成鏡像
[root@Docker2 ~]# docker run -itd --name newweb myweb:latest //啟動(dòng)一個(gè)容器
[root@Docker2 ~]# docker exec -it newweb /bin/bash //進(jìn)入容器
[root@4e419b580248 /]# nginx
[root@4e419b580248 /]# nginx //確定已啟動(dòng)nginx服務(wù)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[root@4e419b580248 /]# curl 127.0.0.1
TEST WEB

注:這里我們可以看見(jiàn)在docker1主機(jī)容器中搭建的簡(jiǎn)單nginx環(huán)境并制作成鏡像成功的遷移到了docker2主機(jī)上了

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。

香港服務(wù)器租用

版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開(kāi)通

自選配置、實(shí)時(shí)開(kāi)通

免備案

全球線路精選!

全天候客戶(hù)服務(wù)

7x24全年不間斷在線

專(zhuān)屬顧問(wèn)服務(wù)

1對(duì)1客戶(hù)咨詢(xún)顧問(wèn)

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部