In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use Docker to deploy open source projects in CentOS8, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
First, install Docker
1. I have a Centos7,linux 3.10 kernel installed on a virtual machine. Docker officials say that it is at least 3.8. it is recommended that more than 3.10 (for ubuntu, linux kernel 3.8or above)
Log in to your root account and check the kernel version as follows
Uname-a
2. Update the yum package to the latest
Yum update
(to select confirmation during the period, enter y)
3. Install the required software packages. Yum-util provides yum-config-manager functions, and the other two are dependent on devicemapper drivers.
Yum install-y yum-utils device-mapper-persistent-data lvm2
4. Set the yum source
Yum-config-manager-add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo (Ali warehouse)
5. You can view all docker versions in all repositories and select a specific version to install
Yum list docker-ce-- showduplicates | sort-r
6. Install Docker, command: yum install docker-ce- version number, I chose docker-ce-18.03.1.ce, as follows
Yum install docker-ce-18.03.1.ce
(to select confirmation during the period, enter y)
7. Start Docker, command: systemctl start docker, and then add boot boot, as follows:
Systemctl start docker # launch docker
Systemctl enable docker # sets docker to boot [/ code] [code] sudo docker run-- rm hello-world # starts hello-word in docker
8. If you see the figure as follows:
Then the installation of doceker is successful
Second, install doceker-compose next
1. Run the following command to download the current stable version of Docker Compose:
Sudo curl-L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname-s)-$(uname-m)"-o / usr/local/bin/docker-compose
2. Apply executable permissions to binaries:
Sudo chmod + x / usr/local/bin/docker-compose
3. Note: if the command docker-compose fails after installation, please check your path. You can also create symbolic links to / usr/bin or any other directory in the path.
For example:
Sudo ln-s / usr/local/bin/docker-compose / usr/bin/docker-compose
4. Check whether docker-compose is installed successfully
Doceker-compose-version
3. Install and configure Git
1. There is yum to install Git on Linux, which is very simple and requires only one command:
Yum-y install git
Enter:
Git-version
Check whether the installation of Git is complete and check its version number
2. Configure git:
Git config global user.name "xxx" git config-global user.email "xxxxx@xx.com" git config-global core.autocrlf falsegit config-global gui.encoding utf-8
3. Execute the following command and enter until the end
Ssh-keygen-t rsa-C xxxxx@xxx.com
4. Generate ssh key
Cat / .ssh/id_rsa.pub
5. Log in to GitHub and click setting > SSHand GPG keys > New SSH Key to copy the generated key to Key.
6. Test whether the configuration is successful
Ssh-T git@github.com
7. Such a paragraph appears, which proves that the configuration is successful.
Hi RoninLee! You've successfully authenticated, but GitHub does not provide shell access.
IV. Back-end deployment
1. Run the following command to pull up the source code:
Git clone https://github.com/bigbaser/TcloudServer.git
2. Go to the TcloudServer\ deploy directory and use the following command to pull all (wait a while, pull for a long time)
Docker-compose pull
3. Then modify the local_config.py file
# the account password here is configured in docker-compose.yml and changed to the following SQLALCHEMY_DATABASE_URI = 'mysql://root:tc123456@mysql:3306/demo?charset=utf8'
4. Initialize the database of kong (if an error is reported, execute it again, and Database is up-to-date will be displayed if it is successful)
After the $sudo docker-compose up-d kong_database// container is started, the database will be locally mounted into. / volumes/kong_database / / but initialization of the database will fail due to permission problems, so give the file permission $sudo chmod-R 777. / volumes/kong_database$ sudo docker-compose run-- rm kong kong migrations bootstrap first.
5. Then start all projects
$sudo docker-compose up-d
6. Check the startup status
$sudo docker-compose ps
7. If all statuses are up, the operation is normal, otherwise check the log.
Sudo docker logs View Log
8. Open konga (the management page of kong, http://localhost:9001), register your account and log in, and then create a new connection with the address of http://kong:8001.
9. After success, go to the SNAPSHOT page, click IMPORT FROM FILE, select our kong.json file, and enter RESTORE in DETAILS. Select all of them and import them all. You may make an error and execute it again. By this time, our gateway service is running at the address of http://localhost:9000.
Ps: the database initialization file is init/init.sql. You can use sudo docker-compose down-v to delete the volume/mysql mount directory and then sudo docker-compose up-d to reinitialize the database.
V. Front-end deployment
1. Install the node environment
Install Node.js and npm from the CentOS repository
You can install Node.js and npm from the standard CentOS repository.
List the modules that provide the nodejs package by running the following command:
Yum module list nodejs
To install the default Node.js package on a CentOS system, enter:
Sudo yum module install nodejs
Enter the following command:
Node-- version # check whether node is installed successfully npm-- version # check whether npm is installed successfully
2. Use the following command to pull the frontend code:
Git clone https://github.com/bigbaser/Tcloud.git
3. Execute under the root directory of the front-end project: npm install installs the dependency package
4. The following error is reported when installing the dependency package:
Solution:
4.1. Enter the following command:
Npm install-g cnpm-- registry= https://registry.npm.taobao.org
4.2. Establish a soft link:
Sudo ln-s {here is the path where you install npm} .npm-global/bin/cnpm / usr/local/bin/cnpm
4.3. Enter:
Cnpm-- version checks whether the installation is successful.
5. Change the BASE_URL address in config/dev.env.js and index.js files to http://0.0.0.0
6. Run the front-end project:
Npm run dev
7. If the login is not successful under a non-localhost domain, you can open the developer tool to check whether the Cookies under Application has JWT_TOKEN_TCLOUD_DEV.
If not, find the front-end project Tcloud/src/store/modules/login.js, modify line 57, and set the
Domain: process.env.NODE_ENV = = 'development'? 'localhost': COOKIE_DOMAIN is modified to: domain: COOKIE_DOMAIN
Then modify the dev.env.js under config to change the COOKIE_DOMAIN to the current access domain name at the front end.
VI. Summary of reporting errors:
1. Docker pull image Times error:
1 、
ERROR: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on such host
2 、
ERROR: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on xxx.xxx.xxx.xxx:xxxx: lame referral
3 、
Error response from daemon: Get https://index.docker.io/v1/search?q=sameersbn&n=25: dial tcp: lookup index.docker.io on 192.168.65.1 dial tcp: read udp 192.168.65.2 Get 45190-> 192.168.65.1 dial tcp 53: I timeoutError response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
Second, analyze the problems:
Questions 1 and 2 are due to the fact that the DNS domain name is not resolved.
Question 3 the network connection timed out, which involves many factors.
Third, the solution:
Question: 1, 2:
Vi / etc/resolv.conf add a line of DNS address: for example: nameserver 114.114.114.114 (this method will fail after the server is restarted. Refer to the method 2:vi / etc/sysconfig/network-scripts/ifcfg-ens33 to open the network card configuration file and add: DNS1= "8.8.8.8", DNS2= "114.114.114.114")
After saving, continue to execute the command to pull the image, you can!
Question: 3:
3.1 find available IP at dig @ 114.114.114.114 registry-1.docker.io
3.2 attempt to modify / etc/hosts to force docker.io-related domain names to be resolved to other available IP
3. Save and try again: docker search sameersbn
Some common Docker commands are attached. For more details, please visit: http://www.docker.org.cn/dockerppt/106.html:
-docker ps to view the currently running container
-docker ps-a to view the status of all containers
-docker start/stop id/name starts / stops a container
-docker attach id enters a container (the container also stops running after exiting with exit)
-docker exec-ti id starts a pseudo terminal to enter a container interactively (the container does not stop running after exiting using exit)
-docker images to view local images
-docker rm id/name deletes a container
-docker rmi id/name deletes an image
-docker run-- name test-ti ubuntu / bin/bash copy the ubuntu container and rename it to test and run it, then enter the container in a pseudo-terminal interactive manner and run bash
-docker build-t soar/centos:7.1. Create a mirror named soar/centos:7.1 from the Dockerfile in the current directory
-docker run-d-p 2222 soar/centos:7.1 22-- name testsoar/centos:7.1 creates a container named test with a mirror soar/centos:7.1, runs it in background mode, and maps the port to host port 2222. The P parameter restarts the container host port will be changed.
These are all the contents of the article "how to deploy open source projects using Docker in CentOS8". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.