Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2019-06-03 18:07:57 +08:00
commit 872e636c24
4 changed files with 535 additions and 549 deletions

View File

@ -1,26 +1,28 @@
[#]: collector: (lujun9972)
[#]: translator: (chen-ni)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10934-1.html)
[#]: subject: (French IT giant Atos enters the edge-computing business)
[#]: via: (https://www.networkworld.com/article/3397139/atos-is-the-latest-to-enter-the-edge-computing-business.html)
[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/)
法国 IT 巨头 Atos 进军边缘计算
======
Atos 另辟蹊径,通过一种只有行李箱大小的设备 BullSequana Edge 进军边缘计算。
> Atos 另辟蹊径,通过一种只有行李箱大小的设备 BullSequana Edge 进军边缘计算。
![iStock][1]
法国 IT 巨头 Atos 是最开展边缘计算业务的,他们的产品是一个叫做 BullSequana Edge 的小型设备。和竞争对手们的集装箱大小的设备不同(比如说 Vapor IO 和 Schneider Electronics的产品Atos 的边缘设备完全可以被放进衣柜里。
法国 IT 巨头 Atos 是最近才开展边缘计算业务的,他们的产品是一个叫做 BullSequana Edge 的小型设备。和竞争对手们的集装箱大小的设备不同(比如说 Vapor IO 和 Schneider Electronics 的产品Atos 的边缘设备完全可以被放进衣柜里。
Atos 表示,他们的这个设备使用人工智能应用提供快速响应,适合需要快速响应的领域比如生产 4.0、自动驾驶汽车、健康管理,以及零售业和机场的安保系统。在这些领域,数据需要在边缘进行实时处理和分析。
**[ 延伸阅读:[什么是边缘计算?][2] 以及 [边缘网络和物联网如何重新定义数据中心][3].]**
[延伸阅读:[什么是边缘计算?][2] 以及 [边缘网络和物联网如何重新定义数据中心][3]]
BullSequana Edge 可以作为独立的基础设施单独采购也可以和Atos的边缘软件捆绑采购并且这个软件还是非常出色的。Atos 表示 BullSequana Edge 主要支持三种使用场景:
BullSequana Edge 可以作为独立的基础设施单独采购,也可以和 Atos 的边缘软件捆绑采购并且这个软件还是非常出色的。Atos 表示 BullSequana Edge 主要支持三种使用场景:
* AI人工智能Atos 的边缘计算机视觉软件为监控摄像头提供先进的特征抽取和分析技术,包括人像,人脸,行为等特征。这些分析可以支持系统做出自动化响应。
* AI人工智能Atos 的边缘计算机视觉软件为监控摄像头提供先进的特征抽取和分析技术,包括人像、人脸、行为等特征。这些分析可以支持系统做出自动化响应。
* 大数据Atos 边缘数据分析系统通过预测性和规范性的解决方案,帮助机构优化商业模型。它使用数据湖的功能,确保数据的可信度和可用性。
* 容器Atos 边缘数据容器EDC是一种一体化容器解决方案。它可以作为一个去中心化的 IT 系统在边缘运行,并且可以在没有数据中心的环境下自动运行,而不需要现场操作。
@ -30,15 +32,13 @@ BullSequana Edge 可以作为独立的基础设施单独采购也可以和Ato
虽然大多数边缘设备都被安放在信号塔附近但是考虑到边缘系统可能被安放在任何地方BullSequana Edge 还支持通过无线电、全球移动通信系统GSM或者 Wi-Fi 来进行通信。
Atos 在美国也许不是一个家喻户晓的名字,但是在欧洲它可以和 IBM 相提并论,并且在过去的十年里已经收购了诸如 Bull SA, Xerox IT Outsourcing, 以及 Siemens IT 的 IT 巨头们。
Atos 在美国也许不是一个家喻户晓的名字,但是在欧洲它可以和 IBM 相提并论,并且在过去的十年里已经收购了诸如 Bull SA、施乐 IT 外包以及西门子 IT 等 IT 巨头们。
**关于边缘网络的延伸阅读:**
关于边缘网络的延伸阅读:
* [边缘网络和物联网如何重新定义数据中心][3]
* [边缘计算的最佳实践][4]
* [边缘计算如何提升物联网安全][5]
加入 Network World 的 [Facebook 社区][6] 和 [LinkedIn 社区][7],参与最前沿话题的讨论。
--------------------------------------------------------------------------------
@ -47,7 +47,7 @@ via: https://www.networkworld.com/article/3397139/atos-is-the-latest-to-enter-th
作者:[Andy Patrizio][a]
选题:[lujun9972][b]
译者:[chen-ni](https://github.com/chen-ni)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,499 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (zhang5788)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Getting Started With Docker)
[#]: via: (https://www.ostechnix.com/getting-started-with-docker/)
[#]: author: (sk https://www.ostechnix.com/author/sk/)
Getting Started With Docker
======
![Getting Started With Docker][1]
In our previous tutorial, we have explained **[how to install Docker in Ubuntu][2]** , and how to [**install Docker in CentOS**][3]. Today, we will see the basic usage of Docker. This guide covers the Docker basics, such as how to create a new container, how to run the container, remove a container, how to build your own Docker image from the Container and so on. Let us get started! All steps given below are tested in Ubuntu 18.04 LTS server edition.
### Getting Started With Docker
Before exploring the Docker basics, dont confuse with Docker images and Docker Containers. As I already explained in the previous tutorial, Docker Image is the file that decides how a Container should behave, and Docker Container is the running or stopped stage of a Docker image.
##### 1\. Search Docker images
We can get the images from either from the registry, for example [**Docker hub**][4], or create our own, For those wondering, Docker hub is cloud hosted place where all Docker users build, test, and save their Docker images.
Docker hub has tens of thousands of Docker images. You can search for the any Docker images with **“docker search”** command.
For instance, to search for docker images based on Ubuntu, run:
```
$ sudo docker search ubuntu
```
**Sample output:**
![][5]
To search images based on CentOS, run:
```
$ sudo docker search ubuntu
```
To search images for AWS, run:
```
$ sudo docker search aws
```
For wordpress:
```
$ sudo docker search wordpress
```
Docker hub has almost all kind of images. Be it an operating system, application, or anything, you will find pre-built Docker images in Docker hub. If something youre looking for is not available, you can build it and make it available for public or keep it private for your own use.
##### 2\. Download Docker image
To download Docker image for Ubuntu OS, run the following command from the Terminal:
```
$ sudo docker pull ubuntu
```
The above command will download the latest Ubuntu image from the **Docker hub**.
**Sample output:**
```
Using default tag: latest
latest: Pulling from library/ubuntu
6abc03819f3e: Pull complete
05731e63f211: Pull complete
0bd67c50d6be: Pull complete
Digest: sha256:f08638ec7ddc90065187e7eabdfac3c96e5ff0f6b2f1762cf31a4f49b53000a5
Status: Downloaded newer image for ubuntu:latest
```
![][6]
Download docker images
You can also download a specific version of Ubuntu image using command:
```
$ docker pull ubuntu:18.04
```
Docker allows us to download any images and start the container regardless of the host OS.
For example, to download CentOS image, run:
```
$ sudo docker pull centos
```
All downloaded Docker images will be saved in **/var/lib/docker/** directory.
To view the list of downloaded Docker images, run:
```
$ sudo docker images
```
**Sample output:**
```
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 7698f282e524 14 hours ago 69.9MB
centos latest 9f38484d220f 2 months ago 202MB
hello-world latest fce289e99eb9 4 months ago 1.84kB
```
As you see above, I have downloaded three Docker images **Ubuntu** , **CentOS** and **hello-world**.
Now, let us go ahead and see how to start or run the containers based on the downloaded images.
##### 3\. Run Docker Containers
We can start the containers in two methods. We can start a container either using its **TAG** or **IMAGE ID**. **TAG** refers to a particular snapshot of the image and the **IMAGE ID** is the corresponding unique identifier for that image.
As you in the above results **“latest”** is the TAG for all containers, and **7698f282e524** is the IMAGE ID of **Ubuntu** Docker image, **9f38484d220f** is the image id of CentOS Docker image and **fce289e99eb9** is the image id of **hello_world** Docker image.
Once you downloaded the Docker images of your choice, run the following command to start a Docker container by using its TAG.
```
$ sudo docker run -t -i ubuntu:latest /bin/bash
```
Here,
* **-t** : Assigns a new Terminal inside the Ubuntu container.
* **-i** : Allows us to make an interactive connection by grabbing the standard in (STDIN) of the container.
* **ubuntu:latest** : Ubuntu container with TAG “latest”.
* **/bin/bash** : BASH shell for the new container.
Or, you can start the container using IMAGE ID as shown below:
```
sudo docker run -t -i 7698f282e524 /bin/bash
```
Here,
* **7698f282e524** Image id
After starting the container, youll be landed automatically into the Containers shell (Command prompt):
![][7]
Docker containers shell
To return back to the host systems Terminal (In my case, it is Ubuntu 18.04 LTS) without terminating the Container (guest os), press **CTRL+P** followed by **CTRL+Q**. Now, youll be safely return back to your original host computers terminal window. Please note that the container is still running in the background and we didnt terminate it yet.
To view the list running of containers, run the following command:
```
$ sudo docker ps
```
**Sample output:**
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
32fc32ad0d54 ubuntu:latest "/bin/bash" 7 minutes ago Up 7 minutes modest_jones
```
![][8]
List running containers
Here,
* **32fc32ad0d54** Container ID
* **ubuntu:latest** Docker image
Please note that **Container ID and Docker image ID are different**.
To list all available ( either running or stopped) containers:
```
$ sudo docker ps -a
```
To stop (power off the container) from the hosts shell, run the following command:
```
$ sudo docker stop <container-id>
```
**Example:**
```
$ sudo docker stop 32fc32ad0d54
```
To login back to or attach to the running container, just run:
```
$ sudo docker attach 32fc32ad0d54
```
As you already know, **32fc32ad0d54** is the containers ID.
To power off a Container from inside its shell by typing the following command:
```
# exit
```
You can verify the list of running containers with command:
```
$ sudo docker ps
```
##### 4\. Build your custom Docker images
Docker is not just for downloading and using the existing containers. You can create your own custom docker image as well.
To do so, start any one the downloaded container:
```
$ sudo docker run -t -i ubuntu:latest /bin/bash
```
Now, you will be in the containers shell.
Then, install any software or do what ever you want to do in the container.
For example, let us install **Apache web server** in the container.
Once you did all tweaks, installed all necessary software, run the following command to build your custom Docker image:
```
# apt update
# apt install apache2
```
Similarly, install and test any software of your choice in the Container.
Once you all set, return back to the host systems shell. Do not stop or poweroff the Container. To switch to the host systems shell without stopping Container, press CTRL+P followed by CTRL+Q.
From your host computers shell, run the following command to find the container ID:
```
$ sudo docker ps
```
Finally, create a Docker image of the running Container using command:
```
$ sudo docker commit 3d24b3de0bfc ostechnix/ubuntu_apache
```
**Sample Output:**
```
sha256:ce5aa74a48f1e01ea312165887d30691a59caa0d99a2a4aa5116ae124f02f962
```
Here,
* **3d24b3de0bfc** Ubuntu container ID. As you already, we can
* **ostechnix** Name of the user who created the container.
* **ubuntu_apache** Name of the docker image created by user ostechnix.
Let us check whether the new Docker image is created or not with command:
```
$ sudo docker images
```
**Sample output:**
```
REPOSITORY TAG IMAGE ID CREATED SIZE
ostechnix/ubuntu_apache latest ce5aa74a48f1 About a minute ago 191MB
ubuntu latest 7698f282e524 15 hours ago 69.9MB
centos latest 9f38484d220f 2 months ago 202MB
hello-world latest fce289e99eb9 4 months ago 1.84kB
```
![][9]
List docker images
As you see in the above output, the new Docker image has been created in our localhost system from the running Container.
Now, you can create a new Container from the newly created Docker image as usual suing command:
```
$ sudo docker run -t -i ostechnix/ubuntu_apache /bin/bash
```
##### 5\. Removing Containers
Once youre done all R&D with Docker containers, you can delete if you dont want them anymore.
To do so, First we have to stop (power off) the running Containers.
Let us find out the running containers with command:
```
$ sudo docker ps
```
**Sample output:**
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3d24b3de0bfc ubuntu:latest "/bin/bash" 28 minutes ago Up 28 minutes goofy_easley
```
Stop the running container by using its ID:
```
$ sudo docker stop 3d24b3de0bfc
```
Now, delete the container using command:
```
$ sudo docker rm 3d24b3de0bfc
```
Similarly, stop all containers and delete them if they are no longer required.
Deleting multiple containers one by one can be a tedious task. So, we can delete all stopped containers in one go, just run:
```
$ sudo docker container prune
```
Type **“Y”** and hit ENTER key to delete the containers.
```
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
32fc32ad0d5445f2dfd0d46121251c7b5a2aea06bb22588fb2594ddbe46e6564
5ec614e0302061469ece212f0dba303c8fe99889389749e6220fe891997f38d0
Total reclaimed space: 5B
```
This command will work only with latest Docker versions.
##### 6\. Removing Docker images
Once you removed containers, you can delete the Docker images that you no longer need.
To find the list of the Downloaded Docker images:
```
$ sudo docker images
```
**Sample output:**
```
REPOSITORY TAG IMAGE ID CREATED SIZE
ostechnix/ubuntu_apache latest ce5aa74a48f1 5 minutes ago 191MB
ubuntu latest 7698f282e524 15 hours ago 69.9MB
centos latest 9f38484d220f 2 months ago 202MB
hello-world latest fce289e99eb9 4 months ago 1.84kB
```
As you see above, we have three Docker images in our host system.
Let us delete them by using their IMAGE id:
```
$ sudo docker rmi ce5aa74a48f1
```
**Sample output:**
```
Untagged: ostechnix/ubuntu_apache:latest
Deleted: sha256:ce5aa74a48f1e01ea312165887d30691a59caa0d99a2a4aa5116ae124f02f962
Deleted: sha256:d21c926f11a64b811dc75391bbe0191b50b8fe142419f7616b3cee70229f14cd
```
##### Troubleshooting
Docker wont let you to delete the Docker images if they are used by any running or stopped containers.
For example, when I try to delete a Docker Image with ID **b72889fa879c** , from one of my old Ubuntu server. I got the following error:
```
Error response from daemon: conflict: unable to delete b72889fa879c (must be forced) - image is being used by stopped container dde4dd285377
```
This is because the Docker image that you want to delete is currently being used by another Container.
So, let us check the running Container using command:
```
$ sudo docker ps
```
**Sample output:**
![][10]
Oops! There is no running container.
Let us again check for all containers (Running and stopped) with command:
```
$ sudo docker ps -a
```
**Sample output:**
![][11]
As you see there are still some stopped containers are using one of the Docker images. So, let us delete all of the containers.
**Example:**
```
$ sudo docker rm 12e892156219
```
Similarly, remove all containers as shown above using their respective containers ID.
Once you deleted all Containers, finally remove the Docker images.
**Example:**
```
$ sudo docker rmi b72889fa879c
```
Thats it. Let us verify is there any other Docker images in the host with command:
```
$ sudo docker images
```
For more details, refer the official resource links given at the end of this guide or drop a comment in the comment section below.
Also, download and use the following Docker Ebooks to get to know more about it.
** **Download** [**Free eBook: “Docker Containerization Cookbook”**][12]
** **Download** [**Free Guide: “Understanding Docker”**][13]
** **Download** [**Free Guide: “What is Docker and Why is it So Popular?”**][14]
** **Download** [**Free Guide: “Introduction to Docker”**][15]
** **Download** [**Free Guide: “Docker in Production”**][16]
And, thats all for now. Hope you a got the basic idea about Docker usage.
More good stuffs to come. Stay tuned!
Cheers!!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/getting-started-with-docker/
作者:[sk][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.ostechnix.com/author/sk/
[b]: https://github.com/lujun9972
[1]: https://www.ostechnix.com/wp-content/uploads/2016/04/docker-basics-720x340.png
[2]: http://www.ostechnix.com/install-docker-ubuntu/
[3]: https://www.ostechnix.com/install-docker-centos/
[4]: https://hub.docker.com/
[5]: http://www.ostechnix.com/wp-content/uploads/2016/04/Search-Docker-images.png
[6]: http://www.ostechnix.com/wp-content/uploads/2016/04/Download-docker-images.png
[7]: http://www.ostechnix.com/wp-content/uploads/2016/04/Docker-containers-shell.png
[8]: http://www.ostechnix.com/wp-content/uploads/2016/04/List-running-containers.png
[9]: http://www.ostechnix.com/wp-content/uploads/2016/04/List-docker-images.png
[10]: http://www.ostechnix.com/wp-content/uploads/2016/04/sk@sk-_005-1-1.jpg
[11]: http://www.ostechnix.com/wp-content/uploads/2016/04/sk@sk-_006-1.jpg
[12]: https://ostechnix.tradepub.com/free/w_java39/prgm.cgi?a=1
[13]: https://ostechnix.tradepub.com/free/w_pacb32/prgm.cgi?a=1
[14]: https://ostechnix.tradepub.com/free/w_pacb31/prgm.cgi?a=1
[15]: https://ostechnix.tradepub.com/free/w_pacb29/prgm.cgi?a=1
[16]: https://ostechnix.tradepub.com/free/w_pacb28/prgm.cgi?a=1

View File

@ -0,0 +1,485 @@
[#]: collector: "lujun9972"
[#]: translator: "zhang5788"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
[#]: subject: "Getting Started With Docker"
[#]: via: "https://www.ostechnix.com/getting-started-with-docker/"
[#]: author: "sk https://www.ostechnix.com/author/sk/"
Docker 入门指南
======
![Getting Started With Docker][1]
在我们的上一个教程中,我们已经了解[**如何在ubuntu上安装Docker**][1],和如何在[**CentOS上安装Docker**][2]。今天我们将会了解Docker的一些基础用法。该教程包含了如何创建一个新的docker容器如何运行该容器如何从现有的docker容器中创建自己的Docker镜像等Docker 的一些基础知识操作。所有步骤均在Ubuntu 18.04 LTS server 版本下测试通过。
### 入门指南
在开始指南之前不要混淆Docker镜像和Docker容器这两个概念。在之前的教程中我就解释过Docker镜像是决定Docker容器行为的一个文件Docker容器则是Docker镜像的运行态或停止态。(译者注:在`macOS`下使用docker终端时不需要加`sudo`)
##### 1. 搜索Docker镜像
我们可以从Docker的仓库中获取镜像例如[**Docker hub**][3], 或者自己创建镜像。这里解释一下,`Docker hub`是一个云服务器用来提供给Docker的用户们创建测试和保存他们的镜像。
`Docker hub`拥有成千上万个Docker 的镜像文件。你可以在这里搜索任何你想要的镜像,通过`docker search`命令。
例如搜索一个基于ubuntu的镜像文件只需要运行
```shell
$ sudo docker search ubuntu
```
**Sample output:**
![][5]
搜索基于CentOS的镜像运行
```shell
$ sudo docker search ubuntu
```
搜索AWS的镜像运行
```shell
$ sudo docker search aws
```
搜索`wordpress`的镜像:
```shell
$ sudo docker search wordpress
```
`Docker hub`拥有几乎所有种类的镜像,包含操作系统,程序和其他任意的类型,这些你都能在`docker hub`上找到已经构建完的镜像。如果你在搜索时,无法找到你想要的镜像文件,你也可以自己构建一个,将其发布出去,或者仅供你自己使用。
##### 2. 下载Docker 镜像
下载`ubuntu`的镜像,你需要在终端运行以下命令:
```shell
$ sudo docker pull ubuntu
```
这条命令将会从**Docker hub**下载最近一个版本的ubuntu镜像文件。
**Sample output:**
> ```shell
> Using default tag: latest
> latest: Pulling from library/ubuntu
> 6abc03819f3e: Pull complete
> 05731e63f211: Pull complete
> 0bd67c50d6be: Pull complete
> Digest: sha256:f08638ec7ddc90065187e7eabdfac3c96e5ff0f6b2f1762cf31a4f49b53000a5
> Status: Downloaded newer image for ubuntu:latest
> ```
![下载docker 镜像][6]
你也可以下载指定版本的ubuntu镜像。运行以下命令
```shell
$ docker pull ubuntu:18.04
```
Dokcer允许在任意的宿主机操作系统下下载任意的镜像文件并运行。
例如下载CentOS镜像
```shell
$ sudo docker pull centos
```
所有下载的镜像文件,都被保存在`/var/lib/docker`文件夹下。(译者注:不同操作系统存放的文件夹并不是一致的,具体存放位置请在官方查询)
查看已经下载的镜像列表,可以使用以下命令:
```shell
$ sudo docker images
```
**输出为:**
```shell
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 7698f282e524 14 hours ago 69.9MB
centos latest 9f38484d220f 2 months ago 202MB
hello-world latest fce289e99eb9 4 months ago 1.84kB
```
正如你看到的那样,我已经下载了三个镜像文件:**ubuntu**, **CentOS**和**Hello-world**.
现在,让我们继续,来看一下如何运行我们刚刚下载的镜像。
##### 3. 运行Docker镜像
运行一个容器有两种方法。我们可以使用`TAG`或者是`镜像ID`。`TAG`指的是特定的镜像快照。`镜像ID`是指镜像的唯一标识。
正如上面结果中显示,`latest`是所有镜像的一个标签。**7698f282e524**是Ubuntu docker 镜像的`镜像ID`,**9f38484d220f**是CentOS镜像的`镜像ID`**fce289e99eb9**是hello_world镜像的`镜像ID`。
下载完Docker镜像之后你可以通过下面的命令来使用`TAG`的方式启动:
```shell
$ sudo docker run -t -i ubuntu:latest /bin/bash
```
在这条语句中:
* **-t**: 在该容器中启动一个新的终端
* **-i**: 通过容器中的标准输入流建立交互式连接
* **ubuntu:latest**:带有标签`latest`的ubuntu容器
* **/bin/bash** : 在新的容器中启动`BASH Shell`
或者,你可以通过`镜像ID`来启动新的容器:
```shell
$ sudo docker run -t -i 7698f282e524 /bin/bash
```
在这条语句里:
* **7698f282e524** —`镜像ID`
在启动容器之后,将会自动进入容器的`shell`中(注意看命令行的提示符)。
![][7]
Docker 容器的`Shell`
如果想要退回到宿主机的终端在这个例子中对我来说就是退回到18.04 LTS并且不中断该容器的执行你可以按下`CTRL+P `,再按下`CTRL+Q`。现在你就安全的返回到了你的宿主机系统中。需要注意的是docker 容器仍然在后台运行,我们并没有中断它。
可以通过下面的命令来查看正在运行的容器:
```shell
$ sudo docker ps
```
**Sample output:**
```shell
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
32fc32ad0d54 ubuntu:latest "/bin/bash" 7 minutes ago Up 7 minutes modest_jones
```
![][8]
列出正在运行的容器
可以看到:
* **32fc32ad0d54** `容器 ID`
* **ubuntu:latest** Docker 镜像
需要注意的是,**`容器ID`和Docker `镜像ID`是不同的**
可以通过以下命令查看所有正在运行和停止运行的容器:
```shell
$ sudo docker ps -a
```
在宿主机中断容器的执行:
```shell
$ sudo docker stop <container-id>
```
例如:
```shell
$ sudo docker stop 32fc32ad0d54
```
如果想要进入正在运行的容器中,你只需要运行
```shell
$ sudo docker attach 32fc32ad0d54
```
正如你看到的,**32fc32ad0d54**是一个容器的ID。当你在容器中想要退出时只需要在容器内的终端中输入命令
```shell
# exit
```
你可以使用这个命令查看后台正在运行的容器:
```shell
$ sudo docker ps
```
##### 4. 构建自己的Docker镜像
Docker不仅仅可以下载运行在线的容器你也可以创建你的自己的容器。
想要创建自己的Docker镜像你需要先运行一个你已经下载完的容器
```shell
$ sudo docker run -t -i ubuntu:latest /bin/bash
```
现在,你运行了一个容器,并且进入了该容器。
然后,在该容器安装任意一个软件或做任何你想做的事情。
例如,我们在容器中安装一个**Apache web 服务器**。
当你完成所有的操作安装完所有的软件之后你可以执行以下的命令来构建你自己的Docker镜像
```shell
# apt update
# apt install apache2
```
同样的,安装和测试所有的你想要安装的软件在容器中。
当你安装完毕之后返回的宿主机的终端。记住不要关闭容器。想要返回到宿主机的host而不中断容器。请按下CTRL+P ,再按下CTRL+Q。
从你的宿主机的终端中运行以下命令如寻找容器的ID
```shell
$ sudo docker ps
```
最后从一个正在运行的容器中创建Docker镜像
```shell
$ sudo docker commit 3d24b3de0bfc ostechnix/ubuntu_apache
```
**输出为:**
```shell
sha256:ce5aa74a48f1e01ea312165887d30691a59caa0d99a2a4aa5116ae124f02f962
```
在这里:
* **3d24b3de0bfc** — 指ubuntu容器的ID。
* **ostechnix** — 我们创建的的名称
* **ubuntu_apache** — 我们创建的镜像
让我们检查一下我们新创建的docker镜像
```shell
$ sudo docker images
```
**输出为:**
```shell
REPOSITORY TAG IMAGE ID CREATED SIZE
ostechnix/ubuntu_apache latest ce5aa74a48f1 About a minute ago 191MB
ubuntu latest 7698f282e524 15 hours ago 69.9MB
centos latest 9f38484d220f 2 months ago 202MB
hello-world latest fce289e99eb9 4 months ago 1.84kB
```
![][9]
列出所有的docker镜像
正如你看到的,这个新的镜像就是我们刚刚在本地系统上从运行的容器上创建的。
现在,你可以从这个镜像创建一个新的容器。
```shell
$ sudo docker run -t -i ostechnix/ubuntu_apache /bin/bash
```
##### 5. 移除容器
如果你在docker上的工作已经全部完成你就可以删除哪些你不需要的容器。
想要删除一个容器,首先,你需要停止该容器。
我们先来看一下正在运行的容器有哪些
```shell
$ sudo docker ps
```
**输出为:**
```shell
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3d24b3de0bfc ubuntu:latest "/bin/bash" 28 minutes ago Up 28 minutes goofy_easley
```
使用`容器ID`来停止该容器:
```shell
$ sudo docker stop 3d24b3de0bfc
```
现在,就可以删除该容器了。
```shell
$ sudo docker rm 3d24b3de0bfc
```
你就可以按照这样的方法来删除那些你不需要的容器了。
当需要删除的容器数量很多时,一个一个删除也是很麻烦的,我们可以直接删除所有的已经停止的容器。只需要运行:
```shell
$ sudo docker container prune
```
按下"**Y**",来确认你的操作
```sehll
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
32fc32ad0d5445f2dfd0d46121251c7b5a2aea06bb22588fb2594ddbe46e6564
5ec614e0302061469ece212f0dba303c8fe99889389749e6220fe891997f38d0
Total reclaimed space: 5B
```
这个命令仅支持最新的docker。(译者注仅支持1.25及以上版本的Docker)
##### 6. 删除Docker镜像
当你移除完不要的Docker容器后你也可以删除你不需要的Docker镜像。
列出已经下载的镜像:
```shell
$ sudo docker images
```
**输出为:**
```shell
REPOSITORY TAG IMAGE ID CREATED SIZE
ostechnix/ubuntu_apache latest ce5aa74a48f1 5 minutes ago 191MB
ubuntu latest 7698f282e524 15 hours ago 69.9MB
centos latest 9f38484d220f 2 months ago 202MB
hello-world latest fce289e99eb9 4 months ago 1.84kB
```
由上面的命令可以知道,在本地的系统中存在三个镜像。
使用`镜像ID`来删除镜像。
```shell
$ sudo docekr rmi ce5aa74a48f1
```
**输出为:**
```shell
Untagged: ostechnix/ubuntu_apache:latest
Deleted: sha256:ce5aa74a48f1e01ea312165887d30691a59caa0d99a2a4aa5116ae124f02f962
Deleted: sha256:d21c926f11a64b811dc75391bbe0191b50b8fe142419f7616b3cee70229f14cd
```
**解决问题**
Docker禁止我们删除一个还在被容器使用的镜像。
例如当我试图删除Docker镜像**b72889fa879c**时,我只能获得一个错误提示:
```shell
Error response from daemon: conflict: unable to delete b72889fa879c (must be forced) - image is being used by stopped container dde4dd285377
```
这是因为这个Docker镜像正在被一个容器使用。
所以,我们来检查一个正在运行的容器:
```shell
$ sudo docker ps
```
**输出为:**
![][10]
注意,现在并没有正在运行的容器!!!
查看一下所有的容器(包含所有的正在运行和已经停止的容器)
```shell
$ sudo docker pa -a
```
**输出为:**
![][11]
可以看到,仍然有一些已经停止的容器在使用这些镜像。
让我们把这些容器删除:
```shell
$ sudo docker rm 12e892156219
```
我们仍然使用容器ID来删除这些容器。
当我们删除了所有使用该镜像的容器之后我们就可以删除Docker的镜像了。
例如:
```shell
$ sudo docekr rmi b72889fa879c
```
我们再来检查一下本机存在的镜像:
```shell
$ sudo docker images
```
想要知道更多的细节,请参阅本指南末尾给出的官方资源的链接或者在评论区进行留言。
或者下载以下的关于Docker的电子书来了解更多。
* **Download** [**Free eBook: “Docker Containerization Cookbook”**][12]
* **Download** [**Free Guide: “Understanding Docker”**][13]
* **Download** [**Free Guide: “What is Docker and Why is it So Popular?”**][14]
* **Download** [**Free Guide: “Introduction to Docker”**][15]
* **Download** [**Free Guide: “Docker in Production”**][16]
这就是全部的教程了希望你可以了解Docker的一些基础用法。
更多的教程马上就会到来,敬请关注。
---
via: https://www.ostechnix.com/getting-started-with-docker/
作者:[sk][a]
选题:[lujun9972][b]
译者:[zhang5788](https://github.com/zhang5788)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.ostechnix.com/author/sk/
[b]: https://github.com/lujun9972
[1]: https://www.ostechnix.com/wp-content/uploads/2016/04/docker-basics-720x340.png
[2]: http://www.ostechnix.com/install-docker-ubuntu/
[3]: https://www.ostechnix.com/install-docker-centos/
[4]: https://hub.docker.com/
[5]: http://www.ostechnix.com/wp-content/uploads/2016/04/Search-Docker-images.png
[6]: http://www.ostechnix.com/wp-content/uploads/2016/04/Download-docker-images.png
[7]: http://www.ostechnix.com/wp-content/uploads/2016/04/Docker-containers-shell.png
[8]: http://www.ostechnix.com/wp-content/uploads/2016/04/List-running-containers.png
[9]: http://www.ostechnix.com/wp-content/uploads/2016/04/List-docker-images.png
[10]: http://www.ostechnix.com/wp-content/uploads/2016/04/sk@sk-_005-1-1.jpg
[11]: http://www.ostechnix.com/wp-content/uploads/2016/04/sk@sk-_006-1.jpg
[12]: https://ostechnix.tradepub.com/free/w_java39/prgm.cgi?a=1
[13]: https://ostechnix.tradepub.com/free/w_pacb32/prgm.cgi?a=1
[14]: https://ostechnix.tradepub.com/free/w_pacb31/prgm.cgi?a=1
[15]: https://ostechnix.tradepub.com/free/w_pacb29/prgm.cgi?a=1
[16]: https://ostechnix.tradepub.com/free/w_pacb28/prgm.cgi?a=1

View File

@ -7,38 +7,38 @@
[#]: via: (https://www.2daygeek.com/check-list-view-find-available-security-updates-on-redhat-rhel-centos-system/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
How To Check Available Security Updates On Red Hat (RHEL) And CentOS System?
如何在 CentOS 或 RHEL 系统上检查可用的安全更新?
======
As per your organization policy you may need to push only security updates due to varies reasons.
当你更新系统时,根据你所在公司的安全策略,有时候可能只需要打上与安全相关的补丁。
In most cases, it could be an application compatibility issues.
大多数情况下,这应该是出于程序兼容性方面的考量。
How to do that? Is it possible to limit yum to perform only security updates?
那该怎样实践呢?有没有办法让 yum 只安装安全补丁呢?
Yes, its possible and can be done easily through yum package manager.
答案是肯定的,可以用 yum 包管理器轻松实现。
In this article, we are not giving only the required information.
在这篇文章中,我们不但会提供所需的信息。
Instead, we have added lot more commands that help you to gather many information about a given security package.
而且,我们会介绍一些额外的命令,可以帮你获取指定安全更新的详实信息。
This may give you an idea or opportunity to understand and fix the list of vulnerabilities, which you have it.
希望这样可以启发你去了解并修复你列表上的那些漏洞。
If security vulnerabilities are discovered, the affected software must be updated in order to limit any potential security risks on system.
一旦有安全漏洞被公布,就必须更新受影响的软件,这样可以降低系统中的安全风险。
For RHEL/CentOS 6 systems, run the following **[Yum Command][1]** to install yum security plugin.
对于 RHEL 或 CentOS 6 系统,运行下面的 **[Yum 命令][1]** 来安装 yum 安全插件。
```
# yum -y install yum-plugin-security
```
The plugin is already a part of yum itself so, no need to install this on RHEL 7&8/CentOS 7&8.
在 RHEL 7&8 或是 CentOS 7&8 上面,这个插件已经是 yum 的一部分了,不用单独安装。
To list all available erratas (it includes Security, Bug Fix and Product Enhancement) without installing them.
只列出全部可用的补丁包括安全Bug 修复以及产品改进),但不安装它们。
```
# yum updateinfo list available
Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
已加载插件: changelog, package_upload, product-id, search-disabled-repos,
: subscription-manager, verify, versionlock
RHSA-2014:1031 Important/Sec. 389-ds-base-1.3.1.6-26.el7_0.x86_64
RHSA-2015:0416 Important/Sec. 389-ds-base-1.3.3.1-13.el7.x86_64
@ -54,20 +54,20 @@ RHBA-2016:1048 bugfix 389-ds-base-1.3.4.0-30.el7_2.x86_64
RHBA-2016:1298 bugfix 389-ds-base-1.3.4.0-32.el7_2.x86_64
```
To count the number of erratas, run the following command.
要统计补丁的大约数量,运行下面的命令。
```
# yum updateinfo list available | wc -l
11269
```
To list all available security updates without installing them.
想列出全部可用的安全补丁但不安装。
It used to display information about both installed and available advisories on your system.
以下命令用来展示你系统里已安装和待安装的推荐补丁。
```
# yum updateinfo list security all
Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
已加载插件: changelog, package_upload, product-id, search-disabled-repos,
: subscription-manager, verify, versionlock
RHSA-2014:1031 Important/Sec. 389-ds-base-1.3.1.6-26.el7_0.x86_64
RHSA-2015:0416 Important/Sec. 389-ds-base-1.3.3.1-13.el7.x86_64
@ -81,13 +81,13 @@ Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
RHSA-2018:1380 Important/Sec. 389-ds-base-1.3.7.5-21.el7_5.x86_64
RHSA-2018:2757 Moderate/Sec. 389-ds-base-1.3.7.5-28.el7_5.x86_64
RHSA-2018:3127 Moderate/Sec. 389-ds-base-1.3.8.4-15.el7.x86_64
RHSA-2014:1031 Important/Sec. 389-ds-base-libs-1.3.1.6-26.el7_0.x86_64
i RHSA-2014:1031 Important/Sec. 389-ds-base-libs-1.3.1.6-26.el7_0.x86_64
```
To print all available advisories security packages (It prints all kind of packages like installed and not-installed).
要显示所有待安装的安全补丁。
```
# yum updateinfo list security all | grep -v "i"
# yum updateinfo list security all | egrep -v "^i"
RHSA-2014:1031 Important/Sec. 389-ds-base-1.3.1.6-26.el7_0.x86_64
RHSA-2015:0416 Important/Sec. 389-ds-base-1.3.3.1-13.el7.x86_64
@ -102,23 +102,23 @@ To print all available advisories security packages (It prints all kind of packa
RHSA-2018:2757 Moderate/Sec. 389-ds-base-1.3.7.5-28.el7_5.x86_64
```
To count the number of available security package, run the following command.
要统计全部安全补丁的大致数量,运行下面的命令。
```
# yum updateinfo list security all | wc -l
3522
```
Its used to list all of the relevant errata notice information, from the updateinfo.xml data in yum. This includes bugzillas, CVEs, security updates and new.
下面根据已装软件列出可更新的安全补丁。这包括 bugzillasbug修复CVEs知名漏洞数据库安全更新等。
```
# yum updateinfo list security
or
或者
# yum updateinfo list sec
Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
已加载插件: changelog, package_upload, product-id, search-disabled-repos,
: subscription-manager, verify, versionlock
RHSA-2018:3665 Important/Sec. NetworkManager-1:1.12.0-8.el7_6.x86_64
@ -134,11 +134,11 @@ RHSA-2018:3665 Important/Sec. NetworkManager-wifi-1:1.12.0-8.el7_6.x86_64
RHSA-2018:3665 Important/Sec. NetworkManager-wwan-1:1.12.0-8.el7_6.x86_64
```
To display all updates that are security relevant, and get a return code on whether there are security updates.
显示所有与安全相关的更新,并且返回一个结果来告诉你是否有可用的补丁。
```
# yum --security check-update
Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock
已加载插件: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock
rhel-7-server-rpms | 2.0 kB 00:00:00
--> policycoreutils-devel-2.2.5-20.el7.x86_64 from rhel-7-server-rpms excluded (updateinfo)
--> smc-raghumalayalam-fonts-6.0-7.el7.noarch from rhel-7-server-rpms excluded (updateinfo)
@ -162,7 +162,7 @@ NetworkManager-libnm.x86_64 1:1.12.0-10.el7_6 rhel-7
NetworkManager-ppp.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms
```
To list all available security updates with verbose descriptions of the issues.
列出所有可用的安全补丁,并且显示其详细信息。
```
# yum info-sec
@ -196,12 +196,12 @@ Description : The tzdata packages contain data files with rules for various
Severity : None
```
If you would like to know more information about the given advisory, run the following command.
如果你想要知道某个更新的具体内容,可以运行下面这个命令。
```
# yum updateinfo RHSA-2019:0163
Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock
已加载插件: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock
rhel-7-server-rpms | 2.0 kB 00:00:00
===============================================================================
Important: kernel security, bug fix, and enhancement update
@ -243,12 +243,12 @@ Description : The kernel packages contain the Linux kernel, the core of any
updateinfo info done
```
Similarly, you can view CVEs which affect the system using the following command.
跟之前类似,你可以只查询那些通过 CVE 释出的系统漏洞。
```
# yum updateinfo list cves
Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
已加载插件: changelog, package_upload, product-id, search-disabled-repos,
: subscription-manager, verify, versionlock
CVE-2018-15688 Important/Sec. NetworkManager-1:1.12.0-8.el7_6.x86_64
CVE-2018-15688 Important/Sec. NetworkManager-adsl-1:1.12.0-8.el7_6.x86_64
@ -260,12 +260,12 @@ CVE-2018-15688 Important/Sec. NetworkManager-ppp-1:1.12.0-8.el7_6.x86_64
CVE-2018-15688 Important/Sec. NetworkManager-team-1:1.12.0-8.el7_6.x86_64
```
Similarly, you can view the packages which is belongs to bugfixs by running the following command.
你也可以查看那些跟 bug 修复相关的更新,运行下面的命令。
```
# yum updateinfo list bugfix | less
Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
已加载插件: changelog, package_upload, product-id, search-disabled-repos,
: subscription-manager, verify, versionlock
RHBA-2018:3349 bugfix NetworkManager-1:1.12.0-7.el7_6.x86_64
RHBA-2019:0519 bugfix NetworkManager-1:1.12.0-10.el7_6.x86_64
@ -277,11 +277,11 @@ RHBA-2018:3349 bugfix NetworkManager-config-server-1:1.12.0-7.el7_6.noarch
RHBA-2019:0519 bugfix NetworkManager-config-server-1:1.12.0-10.el7_6.noarch
```
To get a summary of advisories, which needs to be installed on your system.
要想得到待安装更新的摘要信息,运行这个。
```
# yum updateinfo summary
Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock
已加载插件: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock
rhel-7-server-rpms | 2.0 kB 00:00:00
Updates Information Summary: updates
13 Security notice(s)
@ -293,7 +293,7 @@ Updates Information Summary: updates
updateinfo summary done
```
To print only specific pattern of security advisories, run the following command. Similarly, you can check Important or Moderate security advisories info alone.
如果只想打印出低级别的安全更新,运行下面这个命令。类似的,你也可以只查询重要级别和中等级别的安全更新。
```
# yum updateinfo list sec | grep -i "Low"
@ -310,7 +310,7 @@ via: https://www.2daygeek.com/check-list-view-find-available-security-updates-on
作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
译者:[jdh8383](https://github.com/jdh8383)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出