###

###

Update: 30-03-2019

更新:30 - 03 - 2019

This article has been updated based on the updates to both docker and angular since this article was written. The current version of angular is 7, the updates also adds an attached docker volume to the angular client so that you don't need to run docker-compose build evey time.

自撰写本文以来,本文已基于docker和angular的更新进行了更新。 angular的当前版本为7,更新还向Angular客户端添加了一个附加的docker卷,因此您无需运行docker-compose构建通知时间。

Docker allows us to run applications inside containers. These containers in most cases communicate with each other.

Docker允许我们在容器内运行应用程序。 这些容器在大多数情况下会相互通信。

Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment.

Docker容器将一个软件包装在一个完整的文件系统中,该文件系统包含运行所需的一切:代码,运行时,系统工具,系统库–可以安装在服务器上的任何内容。 这保证了无论其环境如何,该软件将始终运行相同的软件。

We'll build an angular app in one container, point it to an expressjs api in another container, which connects to MongoDB in another container.

我们将在一个容器中构建一个角度应用程序,将其指向另一个容器中的expressjs api,该API在另一个容器中连接到MongoDB。

If you haven't worked with Docker before, this would be a good starting point as we will explain every step covered, in some detail.

如果您以前从未使用过Docker,那么这将是一个不错的起点,因为我们将详细介绍每个步骤。

为什么使用Docker (Why Use Docker)

  1. Docker images usually include only what your application needs to run. As a result, you don't have to worry about having a whole operating system with things you will never user. This results in smaller images of your application.

    Docker映像通常仅包含您的应用程序需要运行的内容。 因此,您不必担心拥有一个永远不会使用的东西的完整操作系统。 这样可以减小应用程序的图像。
  2. Platform Indipendent - I bet you've heard of the phrase 'It worked on my machine, and doesn't work on the server'. With Docker, all either environments need to have is the Docker Engine, or the Docker Daemon, and when we have a successful build of our image, it should run anywhere.

    平台独立人士-我敢打赌您已经听说过“它在我的机器上有效,而在服务器上不起作用”这一短语。 使用Docker,所有环境都需要拥有Docker Engine或Docker Daemon,当我们成功构建映像后,它应该可以在任何地方运行。
  3. Once you have an image of your application built, you can easily share the image to anyone who wants to run your application. They need not worry about dependencies, or setting up their individual environments. All they need to have is Docker Engine installed.

    构建完应用程序的映像后,您可以轻松地将映像共享给想要运行您的应用程序的任何人。 他们不必担心依赖关系,也不必设置自己的环境。 他们所需要的只是安装了Docker Engine。
  4. Isolation - You'll see from the article that I try to separate the individual apps to become indipendent, and only point to each other. The reason behind this is that each part of our entire application should be somewhat indipendent, and scalable on it's own. Docker in this instance would make scaling these individual parts as easy as spinning up another instance of their images. This concept of building isolated, indipendenlty scalable parts of an entire system is what is called Microservices Approach.You can read more about it in Introduction to Microservices

    隔离-从文章中您会看到,我试图将各个应用程序分开以使其相互独立,并且仅指向彼此。 这背后的原因是我们整个应用程序的每个部分都应该是独立的,并且可以自行扩展。 在这种情况下,Docker将使扩展这些单个部分变得像旋转其映像的另一个实例一样容易。 在整个系统中构建隔离的,独立的,可扩展的部分的概念称为微服务方法。您可以在微服务简介中阅读有关它的更多信息。
  5. Docker images usually have tags, referring to their versions. This means you can have versioned builds of your image, enabling you to roll back to a previous version should something unexpected break.

    Docker映像通常具有引用其版本的标签。 这意味着您可以对映像的版本进行版本控制,以便在意外中断时回滚到以前的版本。

先决条件 ( Prerequisites )

You need to have docker and docker-compose installed in your setup. Instructions for installing docker in your given platform can be found here.

您需要在安装程序中安装docker和docker-compose。 可以在此处找到在给定平台上安装docker的说明。

Instructions for installing docker-compose can be found here.

可以在此处找到有关安装docker-compose的说明。

Verify your installation by runnig

通过runnig验证安装

$ docker  -v
Docker version 18.09.2, build 6247962$ docker-compose -v
docker-compose version 1.23.2, build 1110ad01$ node -v
v11.12.0

Next, you need to know how to build a simple Angular app and an Express App. We'll be using the Angular CLI to build a simple app.

接下来,您需要了解如何构建简单的Angular应用程序和Express应用程序。 我们将使用Angular CLI来构建一个简单的应用程序。

单一构建方法 ( Single Builds Approach )

We'll now separately build out these three parts of our app. The approach we are going to take is building the app in our local environment, then dockerizing the app.

现在,我们将分别构建应用程序的这三个部分。 我们将采用的方法是在本地环境中构建应用程序,然后对应用程序进行docker化。

Once these are running, we'll connect the three docker containers. Note that we are only building two containers, Angular and the Express/Node API. The third container will be from a MongoDB image that we'll just pull from the Docker Hub.

一旦这些运行,我们将连接三个docker容器。 请注意,我们仅构建了两个容器,即Angular和Express / Node API。 第三个容器来自MongoDB映像,我们将从Docker Hub中提取该映像。

Docker Hub is a repository for docker images. It's where we pull down official docker images such as MongoDB, NodeJs, Ubuntu, and we can also create custom images and push them to Docker Hub for other people to pull and use.

Docker Hub是Docker映像的存储库。 在这里,我们可以提取MongoDB,NodeJs,Ubuntu等官方docker映像,还可以创建自定义映像并将其推送到Docker Hub,以供其他人提取和使用。

Let's create a directory for our whole set up, we'll call it mean-docker.

让我们为整个设置创建一个目录,我们将其称为mean-docker

$mkdir mean-docker

Angular客户端应用 ( Angular Client App )

Next, we'll create an Angular app and make sure it runs in a docker container.

接下来,我们将创建一个Angular应用,并确保它在docker容器中运行。

Create a directory called angular-client inside the mean-docker directory we created above, and initialize an Angular App with the Angular CLI.

在上面创建的mean-docker目录中创建一个名为angular-client的目录,然后使用Angular CLI初始化Angular App。

We'll use npx, a tool that allows us to run CLI apps without installing them into our system. It comes preinstalled when you install ndeJS since version 5.2.0

我们将使用npx,该工具可让我们运行CLI应用程序而无需将其安装到系统中。 从5.2.0版开始安装ndeJS时,它已预装

$ npx @angular/cli new angular-client? Would you like to add Angular routing? No
? Which stylesheetformat would you like to use? CSS

This scaffolds an angular app, and npm installs the app's dependencies. Our directory structure should be like this

这将搭建一个有角度的应用程序,而npm将安装该应用程序的依赖项。 我们的目录结构应该像这样

└── mean-docker    └── angular-client
        ├── README.md
        ├── angular.json
        ├── e2e
        ├── node_modules
        ├── package.json
        ├── package-lock.json
        ├── src
        ├── tsconfig.json
        └── tslint.json

Running npm start, inside the angular-client directory should start the angular app at http://localhost:4200.

angular-client目录中运行npm start,应在http://localhost:4200处启动angular应用。

Dockerizing Angular 2客户端应用 ( Dockerizing Angular 2 Client App )

To dockerize any app, we usually need to write a Dockerfile

要对任何应用进行Docker化,我们通常需要编写一个Dockerfile

A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

Dockerfile是一个文本文档,其中包含用户可以在命令行上调用以组装映像的所有命令。

To quickly brainstorm on what our angular app needs in order to run,

为了Swift就如何运行我们的角度应用程序进行头脑风暴,

  1. We need an image with nodejs installed on it

    我们需要一个安装了nodejs的图像
  2. We could have the Angular CLI installed on the image, but the package.json file has it as a dependency, so it's not a requirement.

    我们可以在映像上安装Angular CLI,但是package.json文件将其作为依赖项,因此不是必需的。
  3. We can add our angular app into the image and install it's dependencies.

    我们可以将我们的角度应用程序添加到图像中并安装其依赖项。
  4. It needs to expose port 4200 so that we can access it from our host machine through localhost:4200.

    它需要公开端口4200,以便我们可以通过localhost:4200从主机访问它。
  5. If all these requirements are met, we can run npm start in the container, which in turn runs ng serve since it's a script in the package.json file, created from the image and our app should run.

    如果满足所有这些要求,我们可以在容器中运行npm start ,而容器又运行ng serve因为它是package.json文件中的脚本,是从映像创建的,并且我们的应用程序应该运行。

Those are the exact instructions we are going to write in our Dockerfile.

这些是我们要在Dockerfile中编写的确切说明。

mean-docker/angular-client/Dockerfile

均值 -docker /角度 - 客户端/ Dockerfile

# Create image based on the official Node 10 image from dockerhub
FROM node:10# Create a directory where our app will be placed
RUN mkdir -p /app# Change directory so that our commands run inside this new directory
WORKDIR /app# Copy dependency definitions
COPY package*.json /app/# Install dependecies
RUN npm install# Get all the code needed to run the app
COPY . /app/# Expose the port the app runs in
EXPOSE 4200# Serve the app
CMD ["npm", "start"]

I've commented on the file to show what each instruction clearly does.

我对文件进行了评论,以显示每个指令的明确作用。

NOTE Before we build the image, if you are keen, you may have noticed that the line COPY . /app/ copies our whole directory into the container, including node_modules. To ignore this, and other files that are irrelevant to our container, we can add a .dockerignore file and list what is to be ignored. This file is usually sometimes identical to the .gitignore file.

注意在创建映像之前,如果您很热衷,您可能已经注意到COPY . /app/COPY . /app/ COPY . /app/整个目录复制到容器中,包括node_modules 。 要忽略此内容以及与容器不相关的其他文件,我们可以添加.dockerignore文件并列出要忽略的内容。 该文件通常有时与.gitignore文件相同。

Create a .dockerignore file.

创建一个.dockerignore文件。

mean-docker/angular-client/.dockerignore

均值 -docker /角度 - 客户端/.dockerignore

node_modules/

One last thing we have to do before building the image, is to ensure that the app is served from the host created by the docker image. To ensure this, go into your package.json and change the start script to.

构建映像之前,我们要做的最后一件事是确保从docker映像创建的主机上提供应用程序。 为此,请进入package.json并将start脚本更改为。

mean-docker/angular-client/package.json

均值 -docker / angular - client / package.json

{..."scripts": {"start": "ng serve --host 0.0.0.0",...},...
}

To build the image we will use docker build command. The syntax is

要构建映像,我们将使用docker build命令。 语法是

$ docker build -t<image_tag>:<tag> <directory_with_Dockerfile>

Make sure you are in the mean_docker/angular-client directory, then build your image.

确保您位于mean_docker/angular-client目录中,然后构建映像。

$cd angular-client
$ docker build -t angular-client:dev .

-t is a shortform of --tag, and refers to the name or tag given to the image to be built. In this case the tag will be angular-client:dev.

-t--tag ,指代要构建的映像的名称或标记。 在这种情况下,标签将是angular-client:dev

The . (dot) at the end refers to current directory. Docker will look for the Dockerfile in our current directory and use it to build an image.

. 末尾的(点)表示当前目录。 Docker将在当前目录中查找Dockerfile并使用它来构建映像。

This could take a while depending on your internet connection.

这可能需要一段时间,具体取决于您的互联网连接。

Now that the image is built, we can run a container based on that image, using this syntax

现在已经构建了映像,我们可以使用以下语法在该映像的基础上运行一个容器

$ docker run -d --name<container_name> -p <host-port:exposed-port>  <image-name>

The -d flag tells docker to run the container in detached mode. Meaning, it will run and get you back to your host, without going into the container.

-d标志告诉docker以detached模式运行容器。 意思是,它将运行并带您回到主机,而无需进入容器。

$ docker run -d --name angular-client -p 4200:4200 angular-client:dev
8310253fe80373627b2c274c5a9de930dc7559b3dc8eef4abe4cb09aa1828a22

--name refers to the name that will be assigned to the container.

--name是指将分配给容器的名称。

-p or --port refers to which port our host machine should point to in the docker container. In this case, localhost:4200 should point to dockerhost:4200, and thus the syntax 4200:4200.

-p--port指的是我们的主机应在Docker容器中指向哪个端口。 在这种情况下, localhost:4200应该指向dockerhost:4200 ,因此语法为4200:4200

Visit localhost:4200 in your host browser should be serving the angular app from the container.

在您的主机浏览器中访问localhost:4200应该从容器中提供angular应用程序。

You can stop the container running with

您可以停止容器运行

$ docker stop angular-client

Dockerize Express服务器API ( Dockerize the Express Server API )

We've containerized the angular app, we are now two steps away from our complete set up.

我们已经对angular应用程序进行了容器化,距离完成设置只有两个步骤。

Containerizing an express app should now be straight forward. Create a directory in the mean-docker directory called express-server.

现在,将快递应用程序容器化应该很简单。 在mean-docker目录中创建一个名为express-server目录。

$mkdir express-server

Add the following package.json file inside the app.

在应用程序内添加以下package.json文件。

mean-docker/express-server/package.json

均值 -docker / express - server / package.json

{"name": "express-server","version": "0.0.0","private": true,"scripts": {"start": "node server.js"},"dependencies": {"body-parser": "~1.15.2","express": "~4.14.0"}
}

Then, we'll create a simple express app inside it. Create a file server.js

然后,我们将在其中创建一个简单的Express应用。 创建一个文件server.js

$cd express-serve$ touch server.js$ mkdir routes && cd routes$ touch api.js

mean-docker/express-server/server.js

均值 -docker / express - server / server.js

// Get dependencies
const express = require('express');
const path = require('path');
const http = require('http');
const bodyParser = require('body-parser');// Get our API routes
const api = require('./routes/api');const app = express();// Parsers for POST data
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));// Set our api routes
app.use('/', api);// _Get port from environment and store in Express.
_**
const port = process.env.PORT || '3000';
app.set('port', port);
**
// _Create HTTP server._
const server = http.createServer(app);/_*_ Listen on provided port, on all network interfaces.*/
server.listen(port, () => console.log(`API running on localhost:${port}`));

mean_docker/express-server/routes/api.js

意思 _ 泊坞窗/快递 - 服务器/路由/ api.js

const express = require('express');
const router = express.Router();/_ GET api listing. _/
router.get('/', (req, res) => {res.send('api works');
});module.exports = router;

This is a simple express app, install the dependencies and start the app.

这是一个简单的快速应用程序,安装依赖项并启动该应用程序。

$npm install
$ npm start

Going to localhost:3000 in your browser should serve the app.

在浏览器中转到localhost:3000即可投放该应用。

To run this app inside a docker container, we'll also create a Dockerfile for it. It should be pretty similar to what we already have for the angular-client.

为了在Docker容器中运行此应用程序,我们还将为其创建一个Dockerfile。 它应该与我们为angular-client已经拥有的非常相似。

mean-docker/express-server/Dockerfile

平均 - 泊坞窗/快递 - 服务器/ Dockerfile

# Create image based on the official Node 6 image from the dockerhub
FROM node:6# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app# Copy dependency definitions
COPY package.json /usr/src/app# Install dependecies
RUN npm install# Get all the code needed to run the app
COPY . /usr/src/app# Expose the port the app runs in
EXPOSE 3000# Serve the app
CMD ["npm", "start"]

You can see the file is pretty much the same as the angular-client Dockerfile, except for the exposed port.

您可以看到该文件与angular-client Dockerfile几乎相同,除了公开的端口。

You could also add a .dockerignore file to ignore files we do not need.

您还可以添加.dockerignore文件来忽略我们不需要的文件。

mean-docker/express-server/.dockerignore

平均 - 泊坞窗/快递 - 服务器/ .dockerignore

node_modules/

We can then build the image and run a container based on the image with.

然后,我们可以构建图像并基于图像运行容器。

$ docker build -t express-server:dev.
$ docker run -d --name express-server -p 3000:3000 express-server:dev

Going to localhost:3000 in your browser should serve the api.

在浏览器中转到localhost:3000应该可以使用该api。

Once you are done, you can stop the container with

完成后,您可以使用

$ docker stop express-server

MongoDB容器 ( MongoDB container )

The last part of our MEAN set up, before we connect them all together is the MongoDB. Now, we can't have a Dockerfile to build a MongoDB image, because one already exists from the Docker Hub. We only need to know how to run it.

在将它们连接在一起之前,MEAN设置的最后一部分是MongoDB。 现在,我们无法使用Dockerfile来构建MongoDB映像,因为Docker Hub中已经存在一个映像。 我们只需要知道如何运行它。

Assuming we had a MongoDB image already, we'd run a container based on the image with

假设我们已经有一个MongoDB映像,我们将基于该映像运行一个容器

$ docker run -d --name mongodb -p 27017:27017 mongo

The image name in this instance is mongo, the last parameter, and the container name will be mongodb.

该实例中的映像名称是mongo ,最后一个参数,而容器名称将是mongodb

Docker will check to see if you have a mongo image already downloaded, or built. If not, it will look for the image in the Dockerhub. If you run the above command, you should have mongodb instance running inside a container.

Docker将检查您是否已经下载或构建了mongo映像。 如果没有,它将在Dockerhub中查找映像。 如果运行上述命令,则应该在容器内运行mongodb实例。

To check if mongodb is running, simply go to http://localhost:27017 in you browser, and you should see this message. It looks like you are trying to access MongoDB over HTTP on the native driver port.

要检查mongodb是否正在运行,只需在浏览器中转到http://localhost:27017 ,您应该会看到此消息。 It looks like you are trying to access MongoDB over HTTP on the native driver port.

Alternatively, if you have mongo installed in your host machine, simply run mongo in the terminal. And it should run and give you the mongo shell, without any errors.

另外,如果您在主机中安装了mongo,只需在终端中运行mongo 。 它应该运行并为您提供mongo shell,而不会出现任何错误。

Docker撰写 ( Docker Compose )

To connect and run multiple containers with docker, we use Docker Compose.

要使用Docker连接并运行多个容器,我们使用Docker Compose。

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration.

Compose是用于定义和运行多容器Docker应用程序的工具。 通过Compose,您可以使用Compose文件配置应用程序的服务。 然后,使用单个命令,从您的配置中创建并启动所有服务。

Docker compose is usually installed when you install docker. So to simply check if you have it installed, run

Docker compose通常在安装docker时安装。 因此,只需检查是否已安装,请运行

$ docker-compose

You should see a list of commands from docker-compose. If not, you can go through the installation here

您应该看到docker-compose中的命令列表。 如果没有,您可以在这里进行安装

Note: Ensure that you have docker-compose version 1.6 and above by running docker-compose -v

注意 :通过运行docker-compose -v确保您具有docker-compose版本1.6及更高版本

Create a docker-compose.yml file in the root of our set up.

在设置的根目录中创建一个docker-compose.yml文件。

$touch docker-compose.yml

Our directory tree should now look like this.

现在,目录树应如下所示。

.
├── angular-client
├── docker-compose.yml
└── express-server

Then edit the docker-compose.yml file

然后编辑docker-compose.yml文件

mean-docker/docker-compose.yml

意思是 -docker / docker - composeyml

version: '2' # specify docker-compose version# Define the services/containers to be run
services:angular: # name of the first servicebuild: angular-client # specify the directory of the Dockerfileports:- "4200:4200" # specify port forewardingexpress: #name of the second servicebuild: express-server # specify the directory of the Dockerfileports:- "3000:3000" #specify ports forewardingdatabase: # name of the third serviceimage: mongo # specify image to build container fromports:- "27017:27017" # specify port forewarding

The docker-compose.yml file is a simple configuration file telling docker compose which continers to build. That's pretty much it.

docker-compose.yml文件是一个简单的配置文件,告诉docker compose要构建的容器。 就是这样。

Now, to run containers based on the three images, simply run

现在,要基于三个图像运行容器,只需运行

$ docker-compose up

This will build the images if not already built, and run them. Once it's running, and your terminal looks something like this.

如果尚未生成映像,则将生成它们并运行它们。 一旦运行,您的终端将如下所示。

You can visit all the three apps, http://localhost:4200, http://localhost:3000 or mongodb://localhost:27017, and you'll see that all the three containers are running.

您可以访问所有三个应用程序http://localhost:4200http://localhost:3000mongodb://localhost:27017 ,您将看到所有三个容器都在运行。

连接3个Docker容器 ( Connecting the 3 Docker containers )

Finally, the fun part.

最后,有趣的部分。

Express和MongoDb (Express and MongoDb)

We now finally need to connect the three containers. We'll first create a simple CRUD feature in our api using mongoose. You can go through Easily Develop Node.js and MongoDB Apps with Mongoose to get a more detailed explanation of mongoose.

现在,我们终于需要连接三个容器。 我们将首先使用mongoose在我们的api中创建一个简单的CRUD功能。 您可以使用Mongoose轻松地开发Node.js和MongoDB Apps,以获得有关Mongoose的更详细说明。

First of all, add mongoose to your express server package.json

首先,将猫鼬添加到快递服务器package.json

mean-docker/express-server/package.json

均值 -docker / express - server / package.json

{"name": "express-server","version": "0.0.0","private": true,"scripts": {"start": "node server.js"},"dependencies": {"body-parser": "~1.15.2","express": "~4.14.0","mongoose": "^4.7.0"}
}

We need to update our api to use mongo

我们需要更新我们的API以使用mongo

mean-docker/express-server/routes/api.js

意思是 - 泊坞窗/快递 - 服务器/路由/ api.js

// Import dependencies
const mongoose = require('mongoose');
const express = require('express');
const router = express.Router();// MongoDB URL from the docker-compose file
const dbHost = 'mongodb://database/mean-docker';// Connect to mongodb
mongoose.connect(dbHost);// create mongoose schema
const userSchema = new mongoose.Schema({name: String,age: Number
});// create mongoose model
const User = mongoose.model('User', userSchema);/_ GET api listing. _/
router.get('/', (req, res) => {res.send('api works');
});/_ GET all users. _/
router.get('/users', (req, res) => {User.find({}, (err, users) => {if (err) res.status(500).send(error)res.status(200).json(users);});
});/_ GET one users. _/
router.get('/users/:id', (req, res) => {User.findById(req.param.id, (err, users) => {if (err) res.status(500).send(error)res.status(200).json(users);});
});/_ Create a user. _/
router.post('/users', (req, res) => {let user = new User({name: req.body.name,age: req.body.age});user.save(error => {if (error) res.status(500).send(error);res.status(201).json({message: 'User created successfully'});});
});module.exports = router;

Two main differences, first of all our connection to mongo db is in the line const dbHost = 'mongodb://database/mean-docker';. This database is the same as the database service we created in the docker-compose file.

两个主要区别是,首先我们与mongo db的连接是在const dbHost = 'mongodb://database/mean-docker'; 。 该database与我们在docker-compose文件中创建的数据库服务相同。

We've also added rest routes GET /users, GET /users/:id and POST /user.

我们还添加了休息路线GET /usersGET /users/:idPOST /user

Update the docker-compose file, telling the express service to link to the database service.

更新docker-compose文件,告诉Express服务链接到数据库服务。

mean-docker/docker-compose.yml

意思是 -docker / docker - composeyml

version: '2' # specify docker-compose version# Define the services/containers to be run
services:angular: # name of the first servicebuild: angular-client # specify the directory of the Dockerfileports:- "4200:4200" # specify port forewardingvolumes:- ./angular-client:/app # this will enable changes made to the angular app reflect in the containerexpress: #name of the second servicebuild: express-server # specify the directory of the Dockerfileports:- "3000:3000" #specify ports forewardinglinks:- databasedatabase: # name of the third serviceimage: mongo # specify image to build container fromports:- "27017:27017" # specify port forewarding

The links property of the docker-compose file creates a connection to the other service with the name of the service as the host name. In this case database will be the hostname. Meaning, to connect to it frrom the express service, we should use database:27017. That's why we made the dbHost equal to mongodb://database/mean-docker.

docker-compose文件的links属性创建以服务名称作为主机名的另一服务的连接。 在这种情况下, database将是主机名。 意思是,要从express服务连接到它,我们应该使用database:27017 。 这就是为什么我们使dbHost等于mongodb://database/mean-docker

Also, I've added a volumes to the angular service. This will enable changes we make to the Angular App automatically trigger recompilation in the container

另外,我还向角度服务添加了一个卷。 这将启用我们对Angular App所做的更改,从而自动触发容器中的重新编译

角度和快速 (Angular and Express)

The last part is to connect the Angular app to the express server. To do this, we'll need to make some modifications to our angular app to consume the express api.

最后一部分是将Angular应用程序连接到快递服务器。 为此,我们需要对我们的角度应用程序进行一些修改以使用Express API。

Add the Angular HTTP Client. mean-docker/angular-client/src/app.module.ts

添加Angular HTTP客户端。 均值 - 泊坞窗/角 - 客户端/src/app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http'; // add http client moduleimport { AppComponent } from './app.component';@NgModule({declarations: [AppComponent],imports: [BrowserModule,HttpClientModule // import http client module],providers: [],bootstrap: [AppComponent]
})
export class AppModule { }

mean-docker/angular-client/src/app/app.component.ts

均值 - 泊坞窗/角 - 客户端/src/app/app.component.ts

import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';@Component({selector: 'app-root',templateUrl: './app.component.html',styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {title = 'app works!';// Link to our api, pointing to localhostAPI = 'http://localhost:3000';// Declare empty list of peoplepeople: any[] = [];constructor(private http: HttpClient) {}// Angular 2 Life Cycle event when component has been initializedngOnInit() {this.getAllPeople();}// Add one person to the APIaddPerson(name, age) {this.http.post(`${this.API}/users`, {name, age}).subscribe(() => {this.getAllPeople();})}// Get all users from the APIgetAllPeople() {this.http.get(`${this.API}/users`).subscribe((people: any) => {console.log(people)this.people = people})}
}

Angular best practices guides usually recommend separating most logic into a service/provider. We've placed all the code in the component here for brevity.

Angular最佳实践指南通常建议将大多数逻辑分为服务/提供者。 为了简洁起见,我们将所有代码都放在了组件中。

We've imported the OnInit interface, to call events when the component is initialized, then added a two methods AddPerson and getAllPeople, that call the API.

我们已经导入了OnInit接口,以在初始化组件时调用事件,然后添加了两个调用API的方法AddPersongetAllPeople

Notice that this time round, our API is pointing to localhost. This is because while the angular 2 app will be running inside the container, it's served to the browser. And the browser is the one that makes request. It will thus make a request to the exposed express API. As a result, we don't need to link Angular and Express in the docker-compose.yml file.

请注意,这一次,我们的API指向localhost 。 这是因为虽然angular 2应用程序将在容器内运行,但已将其提供给浏览器。 浏览器是发出请求的浏览器。 因此,它将向公开的Express API发出请求。 因此,我们不需要在docker-compose.yml文件中链接Angular和Express。

Next, we need to make some changes to the template. I first added bootstrap via cdn to the index.html

接下来,我们需要对模板进行一些更改。 我首先通过CDN将引导程序添加到index.html

mean-docker/angular-client/src/app/index.html

均值 - 泊坞窗/角 - 客户端/src/app/index.html

<!doctype html>
<html>
<head><meta charset="utf-8"><title>Angular Client</title><base href="/"><meta name="viewport" content="width=device-width, initial-scale=1"><!-- Bootstrap CDN --><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css"><link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body><app-root>Loading...</app-root>
</body>
</html>

Then update the app.component.html template

然后更新app.component.html模板

mean-docker/angular-client/src/app/app.component.html

均值 - 泊坞窗/角 - 客户端/src/app/app.component.html

<!-- Bootstrap Navbar -->
<nav class="navbar navbar-light bg-faded"><div class="container"><a class="navbar-brand" href="#">Mean Docker</a></div>
</nav><div class="container"><h3>Add new person</h3><form><div class="form-group"><label for="name">Name</label><input type="text" class="form-control" id="name" #name></div><div class="form-group"><label for="age">Age</label><input type="number" class="form-control" id="age" #age></div><button type="button" (click)="addPerson(name.value, age.value)" class="btn btn-primary">Add person</button></form><h3>People</h3><!-- Bootstrap Card --><div class="card card-block col-md-3" *ngFor="let person of people"><h4 class="card-title">{{person.name}}  {{person.age}}</h4></div>
</div>

The above template shows the components properties and bindings. We are almost done.

上面的模板显示了组件的属性和绑定。 我们快完成了。

Since we've made changes to our code, we need to do a build for our Docker Compose

由于我们已经更改了代码,因此需要为Docker Compose做一个构建

$ docker-compose up --build

The --build flag tells docker compose that we've made changes and it needs to do a clean build of our images.

--build标志告诉docker compose我们已经进行了更改,它需要对映像进行干净的构建。

Once this is done, go to localhost:4200 in your browser,

完成此操作后,在浏览器中转到localhost:4200

We are getting a No 'Access-Control-Allow-Origin' error. To quickly fix this, we need to enable Cross-Origin in our express app. We'll do this with a simple middleware.

我们收到No 'Access-Control-Allow-Origin'错误。 为了快速解决此问题,我们需要在Express应用程序中启用Cross-Origin。 我们将使用一个简单的中间件来实现。

mean-docker/express-server/server.js

均值 -docker / express - server / server.js

// Code commented out for brevity// Parsers for POST data
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));// Cross Origin middleware
app.use(function(req, res, next) {res.header("Access-Control-Allow-Origin", "*")res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")next()
})// Set our api routes
app.use('/', api);// Code commented out for brevity

We can now run docker-compose again with the build flag. You should be in the mean-docker directory

现在,我们可以使用build标志再次运行docker-compose。 你应该在均值 - 泊坞窗目录

$ docker-compose up --build

Going to localhost:4200 on the browser.

在浏览器上转到localhost:4200

结论 ( Conclusion )

EDIT: **- ** I added an attached volume to the docker-compose file, and we now no longer need to rebuild the service every time we make a change.

编辑:**- **我向docker-compose文件添加了一个附加卷,现在我们不再需要每次进行更改时都重新构建服务。

I bet you've learned a thing or two about MEAN or docker and docker-compose.

我敢打赌,您已经了解了有关MEAN或docker和docker-compose的一两件事。

The problem with our set up however is that any time we make changes to either the angular app, or the express api, we need to run docker-compose up --build.

但是,设置的问题在于,每当我们对angular应用或express api进行更改时,都需要运行docker-compose up --build

This can get tidious or even boring over time. We'll look at this in the another article.

随着时间的流逝,这可能会变得乏味甚至无聊。 我们将在另一篇文章中对此进行研究。

翻译自: https://scotch.io/tutorials/create-a-mean-app-with-angular-2-and-docker-compose

查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. 美容院楚雄州哪里可以划单眼皮和双眼皮怎么区别

    ...

    2024/4/21 7:06:19
  2. Angular_03_入门_下篇_HTTP

    最终效果如下:附录: github地址: https://github.com/ixixii/angular_tutorial_demo.git cd /Users/beyond/sg_angular/angular_01/angular-tutorial-demo git status git add src/app/ git commit -m first commit git push https://github.com/ixixii/angular_tutorial_demo…...

    2024/4/21 7:06:19
  3. 做埋线双眼皮价格表

    ...

    2024/4/21 7:06:17
  4. Angular1.x解析md并展示(代码高亮+行号展示)

    源码&#xff1a;angular-markdown-it 好像最近和markdown缠上了…? 这两天在研究Angular1.x解析md文件 网上搜了很多&#xff0c;发现好像使用于1.x版本的只有markdown-it这个插件了 对着github上的源码弄了好久 照着他的步骤来的话&#xff0c;可以展示标题呀斜体呀这些md格…...

    2024/4/21 7:06:17
  5. angular 基础知识

    一、程序架构模块&#xff1a;用来将应用中 不同的部分 组织成 一个Angular框架可以理解的单元。 组件&#xff1a;是anguler应用的基本构建块&#xff0c;带有业务逻辑和数据的Html。 服务&#xff1a;用来封装可重用的业务逻辑 指令&#xff1a;允许你向Html元素增加自定义行…...

    2024/4/24 0:56:57
  6. AngularJS实现长按事件监听(ng-onhold)

    用AngularJS做H5手机APP开发的时候碰到的问题&#xff0c;需要实现长按监听的效果。 网上大都是由框架ionic来实现的&#xff0c;因为我的项目没有用到&#xff0c;不想加入额外的框架了&#xff0c;于是就想自己实现。 实现步骤如下&#xff1a; 1. 引入angularjs自带的js附…...

    2024/4/21 7:06:14
  7. 搭建git服务器及利用git hook自动布署代码

    我喜欢 github,我现在的个人代码全部是托管在上面了,但是一些公司或者某些项目不适合放入github中,你希望能有一个完全私有的仓库,如果你有一台服务器,这显然是很容易办到的事。下面简单的描述我在某个项目中布署的一个git服务,并且本地提交更新后,服务器将自动更新代码…...

    2024/4/21 6:11:03
  8. 移动端刷新组件XtnScroll--Angular4实现

    刷新组件 - 主要是学习一下Angular4所有花了我一天时间&#xff0c;写了这个刷新组件。 以项目开发当中&#xff0c;特别是手机移动端开发的时候&#xff0c;经常要用到就是上拉加载下一面&#xff0c;下拉刷新获取最新数据的功能。在网也有很多类似的组件&#xff0c;前段时…...

    2024/4/30 14:13:48
  9. OpenCV4学习笔记(37)——CAMShift(Continuously Adaptive MeanShift)算法

    在上次的笔记《OpenCV4学习笔记(36)——基于均值迁移(MeanShift)算法和直方图反向投影的目标移动跟踪》中,整理记录了一种针对目标的移动跟踪算法,主要是基于均值迁移和直方图反向投影来实现的。而今天要记录的笔记内容,依然是一种针对目标的移动跟踪算法——CAMShift目…...

    2024/4/20 18:55:51
  10. 割双眼皮拆线后消肿

    ...

    2024/4/20 18:55:50
  11. 割双眼皮怎么热敷

    ...

    2024/4/20 18:55:49
  12. 双眼皮两个月了能不能修复

    ...

    2024/4/21 7:06:13
  13. 全切开双眼皮20天还很肿怎么办

    ...

    2024/4/21 0:00:21
  14. 双眼皮用眼线笔好还是眼线液

    ...

    2024/4/20 10:52:16
  15. 做完双眼皮怎么热敷

    ...

    2024/4/21 7:06:09
  16. 割完双眼皮后用什么消炎

    ...

    2024/5/1 6:06:30
  17. 美瞳线和双眼皮能一起做吗

    ...

    2024/5/1 3:11:15
  18. AngularJs ng-bind-html指令整理

    一、使用angular-santize.js <div ng-app"myApp" ng-controller"myCtrl"><p ng-bind-html"myText"></p> </div>var app angular.module("myApp", [ngSanitize]); app.controller("myCtrl", functi…...

    2024/4/21 7:06:06
  19. ngModel:numfmt及ng-true-value、ng-false-value勾选错误

    一 angularjs 报 ngModel:numfmt 错 Error: [ngModel:numfmt] http://errors.angularjs.org/1.5.5/ngModel/numfmt?p01at Error (native)at http://192.168.1.21:8020/AngularJS/js/angular.min.js:6:412at Array.<anonymous> (http://192.168.1.21:8020/AngularJS/js/…...

    2024/4/29 0:08:18
  20. 双眼皮贴打造深邃眼神

    ...

    2024/4/21 7:06:05

最新文章

  1. TCP协议关于速率的优化机制-滑动窗口详解

    在上一章中&#xff0c;我们讲述了TCP协议在传输过程中的可靠性http://t.csdnimg.cn/BsImO&#xff0c;这里衔接上一篇文章继续讲&#xff0c;TCP协议的特性&#xff0c;TCP协议写完之后就写&#xff0c;Http和Https等内容吧 1. 滑动窗口 这里的滑动窗口不是指算法里面的双指…...

    2024/5/1 7:38:47
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. Linux mount用法

    在Linux系统中&#xff0c;系统自动挂载了以下挂载点&#xff1a; /: xfs文件系统&#xff0c;根文件系统, 所有其他文件系统的挂载点。 /sys: sysfs文件系统&#xff0c;提供内核对象的信息和接口。 /proc: proc文件系统&#xff0c;提供进程和系统信息。 /dev: devtmpfs文件系…...

    2024/4/30 3:59:48
  4. linuxday05

    1、makedile原理&#xff08;增量编译生成代码&#xff09; # &#xff08;注释符&#xff09; 目标------依赖 目标不存在//目标比依赖旧才会执行命令&#xff1b; makefile的实现 1、命名要求&#xff08;Makefile/makefile&#xff09; 2、规则的集合 目标文件&#…...

    2024/4/30 1:42:28
  5. 【外汇早评】美通胀数据走低,美元调整

    原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...

    2024/4/29 23:16:47
  6. 【原油贵金属周评】原油多头拥挤,价格调整

    原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...

    2024/4/30 18:14:14
  7. 【外汇周评】靓丽非农不及疲软通胀影响

    原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...

    2024/4/29 2:29:43
  8. 【原油贵金属早评】库存继续增加,油价收跌

    原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...

    2024/4/30 18:21:48
  9. 【外汇早评】日本央行会议纪要不改日元强势

    原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...

    2024/4/27 17:58:04
  10. 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响

    原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...

    2024/4/27 14:22:49
  11. 【外汇早评】美欲与伊朗重谈协议

    原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...

    2024/4/28 1:28:33
  12. 【原油贵金属早评】波动率飙升,市场情绪动荡

    原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...

    2024/4/30 9:43:09
  13. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

    原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...

    2024/4/27 17:59:30
  14. 【原油贵金属早评】市场情绪继续恶化,黄金上破

    原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...

    2024/4/25 18:39:16
  15. 【外汇早评】美伊僵持,风险情绪继续升温

    原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...

    2024/4/28 1:34:08
  16. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

    原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...

    2024/4/26 19:03:37
  17. 氧生福地 玩美北湖(上)——为时光守候两千年

    原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...

    2024/4/29 20:46:55
  18. 氧生福地 玩美北湖(中)——永春梯田里的美与鲜

    原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...

    2024/4/30 22:21:04
  19. 氧生福地 玩美北湖(下)——奔跑吧骚年!

    原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...

    2024/5/1 4:32:01
  20. 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!

    原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...

    2024/4/27 23:24:42
  21. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

    原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...

    2024/4/28 5:48:52
  22. 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者

    原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...

    2024/4/30 9:42:22
  23. 广州械字号面膜生产厂家OEM/ODM4项须知!

    原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...

    2024/4/30 9:43:22
  24. 械字号医用眼膜缓解用眼过度到底有无作用?

    原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...

    2024/4/30 9:42:49
  25. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  26. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  27. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  28. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  29. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  30. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  31. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  32. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  33. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  34. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  35. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  36. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  37. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  38. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  39. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  40. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  41. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  42. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  43. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  44. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57