Implementation of static website layout in docker container

Implementation of static website layout in docker container

Server placement

It is recommended to use cloud servers (Alibaba Cloud, Huawei Cloud, Tencent Cloud) which can be used for free for a few days. After we buy a server, we will encounter the following problems:

The local computer pings the server host and finds that the ping fails and the request times out.

We need to find the security group column in the management server interface, and then add icmp when entering and exiting the security group. It is recommended to add all with one click.


Then we can ping the server from the local computer.

Docker installation

After setting up the cloud server, we use apt-get update, apt-get upgrade to update information.



Then, we enter docker and the following error occurs:


Next, we follow the usual software method apt-get install docker.io, apt-get install docker.ce , and find the following problems

Package 'docker-ce' has no installation candidate

The solution is as follows:

#Add docker source sudo echo "deb https://download.docker.com/linux/ubuntu zesty edge" > /etc/apt/sources.list.d/docker.list

#Support parsing https
apt-get install -y apt-transport-https ca-certificates curl software-properties-common

#Add GPG key curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

#Set the repository location add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Then we execute it again and get the following result


Next, verify the installation result by typing docker run hello-world

nginx installation

The next step is apt-get install nginx install nginx


The next step is to check the installation effect. Enter the command service start nginx , then enter the server's external network IP address in the browser to see the nginx default interface. There are a few problems here:

1.

Problem: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

nginx: [emerg] still could not bind()

Solution: netstat -ntlp | grep 80 to check


Then enter service nginx stop and check again and it is gone.

Problem: nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:86

Solution

vim /etc/nginx/nginx.conf
Add the server {
....
}
Put it in http
...
}
It can be solved

First: mkdir -p /var/www/html
Then cd to the directory and execute vim index.html
Define the content in html yourself, save and exit, and then modify the default index.html path in the configuration file as follows


Then restart nginx, service nginx restart

Browser Testing

Finally, we can start the image of the docker container as follows


Finally, just check the effect. Just enter the address and port number in the browser.

This is the end of this article about the implementation of deploying static websites in docker containers. For more relevant content about deploying static websites in docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Using Docker to create static website applications (multiple ways)

<<:  jQuery implements form validation function

>>:  Steps to install MySQL 8.0.23 under Centos7 (beginner level)

Recommend

Detailed steps to install mysql 8.0.18-winx64 on win10

1. First go to the official website to download t...

Vue Page Stack Manager Details

Table of contents 2. Tried methods 2.1 keep-alive...

Example code for implementing card waterfall layout with css3 column

This article introduces the sample code of CSS3 c...

MySQL detailed summary of commonly used functions

Table of contents MySQL Common Functions 1. Numer...

Detailed explanation of Vue save automatic formatting line break

I searched for many ways to change it online but ...

Image scrolling effect made with CSS3

Achieve resultsImplementation Code html <base ...

Detailed explanation of incompatible changes of components in vue3

Table of contents Functional Components How to wr...

Solution to the problem of saving format in HTML TextArea

The format of textarea can be saved to the databas...

js to realize web music player

This article shares simple HTML and music player ...

A case study on MySQL optimization

1. Background A sql-killer process is set up on e...

Html long text automatically cuts off when it exceeds the tag width

When we display long text, we often need to interc...

How to prevent computer slowdown when WIN10 has multiple databases installed

Enable the service when you need it, and disable ...