Analysis of the process of simply deploying nginx in Docker container

Analysis of the process of simply deploying nginx in Docker container

1. Deploy nginx service in container

The centos:7 image runs a container and deploys the Nginx service in this container.

[root@Docker ~]# docker pull centos:7 //Download the image
[root@Docker ~]# docker run -itd --name webapp --restart=always centos:7 //Run a container named: webapp
[root@Docker ~]# docker cp nginx-1.16.0.tar.gz webapp:/root //Import the local nginx package into the webapp container
[root@Docker ~]# docker exec -it webapp /bin/bash //Enter the container
[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 //Download related dependency packages
[root@85099880dabe nginx-1.16.0]# useradd -M -s /sbin/nologin nginx //Add an nginx user without login permission
[root@85099880dabe nginx-1.16.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx //Compile and install

[root@85099880dabe nginx-1.16.0]# make && make install //Compile and install
[root@85099880dabe nginx-1.16.0]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/ //Create a soft link
[root@85099880dabe nginx-1.16.0]# nginx
[root@85099880dabe nginx-1.16.0]# nginx //Confirm that nginx service is enabled
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. Migrate the image

Required environment:

docker1 host: 192.168.45.129

docker2 host: 192.168.45.134

1) docker1 host

Import the newly created container of docker1 into the docker2 host

[root@Docker ~]# docker commit webapp myweb //Make the webapp container into a mirror named myweb
sha256:b035b8e8a36140e1bdbda9cf3a736b139ea8a48db7871a10f509b8f34d4c0f82
[root@Docker ~]# docker save > myweb.tar myweb:latest //Export the image
[root@Docker ~]# scp myweb.tar 192.168.45.134:/root //cp the exported tarball to the docker2 host
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.
[email protected]'s password: //The password is the password of the docker2 host
myweb.tar 100% 353MB 176.4MB/s 00:02

2) Docker2 host

[root@Docker2 ~]# docker load < myweb.tar //Make the tar package just cp into a mirror
[root@Docker2 ~]# docker run -itd --name newweb myweb:latest //Start a container
[root@Docker2 ~]# docker exec -it newweb /bin/bash //Enter the container
[root@4e419b580248 /]# nginx
[root@4e419b580248 /]# nginx //Confirm that the nginx service has been started
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

Note: Here we can see that the simple nginx environment built in the docker1 host container was successfully migrated to the docker2 host as a mirror.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Docker Nginx container production and deployment implementation method
  • Analysis of the process of simply deploying nginx in Docker container
  • Docker container deployment attempt - multi-container communication (node+mongoDB+nginx)
  • Docker deployment nginx implementation process graphic and text detailed explanation
  • How to deploy Vue project using Docker image + nginx
  • Implementation of Docker deployment of Django+Mysql+Redis+Gunicorn+Nginx
  • How to deploy nginx with Docker and modify the configuration file

<<:  React realizes secondary linkage (left and right linkage)

>>:  5 ways to make your JavaScript codebase cleaner

Recommend

Learn the key knowledge that must be mastered in the Vue framework

1. What is Vue Vue is a progressive framework for...

Details on using bimface in vue

Table of contents 1. Install Vue scaffolding 2. C...

Vue realizes the palace grid rotation lottery

Vue implements the palace grid rotation lottery (...

Solution to the Docker container being unable to access the host port

I recently encountered a problem at work. The doc...

Installation and configuration method of Zabbix Agent on Linux platform

Here is a brief summary of the installation and c...

JavaScript explains the encapsulation and use of slow-motion animation

Implementing process analysis (1) How to call rep...

About browser compatibility issues encountered and solutions (recommended)

Preface: Last Sunday, a senior asked me to help m...

CSS selects the first child element under the parent element (:first-child)

Preface I recently used :first-child in a project...

How to solve the Docker container startup failure

Question: After the computer restarts, the mysql ...

Parameters to make iframe transparent

<iframe src="./ads_top_tian.html" all...

Detailed explanation of Linux zabbix agent deployment and configuration methods

1. Install zabbix-agent on web01 Deploy zabbix wa...

How to solve the mysql ERROR 1045 (28000)-- Access denied for user problem

Problem description (the following discussion is ...

Tutorial on installing mysql5.7.36 database in Linux environment

Download address: https://dev.mysql.com/downloads...

HTML+CSS to achieve responsive card hover effect

Table of contents accomplish: Summarize: Not much...