Skip to content

Commit

Permalink
feat: docker docs
Browse files Browse the repository at this point in the history
  • Loading branch information
suyuan32 committed Apr 26, 2024
1 parent d02ec39 commit 353adf8
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 2 deletions.
24 changes: 23 additions & 1 deletion src/.vuepress/sidebar/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,29 @@ export const enSidebar = sidebar({
icon: "bi:tools",
prefix: "devtools/",
collapsible: true,
children: "structure",
children: [
{
text: "IDE",
icon: "dashicons:editor-code",
prefix: "IDE/",
collapsible: true,
children: "structure",
},
{
text: "Git",
icon: "bx:bx-git-branch",
prefix: "Git/",
collapsible: true,
children: "structure",
},
{
text: "Docker",
icon: "mdi:docker",
prefix: "Docker/",
collapsible: true,
children: "structure",
},
],
},
],
},
Expand Down
24 changes: 23 additions & 1 deletion src/.vuepress/sidebar/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,29 @@ export const zhSidebar = sidebar({
icon: "bi:tools",
prefix: "devtools/",
collapsible: true,
children: "structure",
children: [
{
text: "IDE",
icon: "dashicons:editor-code",
prefix: "IDE/",
collapsible: true,
children: "structure",
},
{
text: "Git",
icon: "bx:bx-git-branch",
prefix: "Git/",
collapsible: true,
children: "structure",
},
{
text: "Docker",
icon: "mdi:docker",
prefix: "Docker/",
collapsible: true,
children: "structure",
},
],
},
],
},
Expand Down
51 changes: 51 additions & 0 deletions src/en/guide/devtools/Docker/1-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
order: 1
title: Docker
icon: mdi:docker
---

## Introduction to Docker

Docker is an open-source application container engine based on Go language and released under the Apache 2.0 license. It allows developers to package their applications and dependencies into a portable container, which can then be deployed on any popular Linux machine or used for virtualization. Containers operate within a sandbox mechanism, isolating them from each other. Similar to virtual machines, containers consume fewer resources. While a typical host can run only dozens of virtual machines, it can simultaneously handle hundreds or thousands of containers.

::: info What is a Container?
A container packages an application along with its dependencies into a single filesystem. It includes everything needed to run, such as code, runtime, system tools, and libraries. Containers ensure that applications can run consistently across any environment. They are platform-independent and can operate in development, testing, and production environments.
:::

### Why Use Docker?

Before containers, developers wrote code in the development environment, deployed it to the testing environment, and finally to production. This approach had issues like inconsistent environments, deployment complexities, and discrepancies between development and production setups. Docker addresses these problems, ensuring consistency across development, testing, and production environments, thereby enhancing development efficiency.

::: info Advantages of Docker

- **Rapid Delivery**: Docker enables quick deployment, allowing containers to start or stop within seconds or tens of seconds.
- **Consistent Runtime Environment**: Docker ensures consistency across development, testing, and production environments.
- **Efficient Resource Utilization**: Multiple containers can run on a single host, improving resource utilization.
- **Lightweight**: Docker shares the host kernel, avoiding the need for a full operating system, making it lighter than virtual machines.
- **Ease of Maintenance**: Docker facilitates rapid deployment, startup, and shutdown, resulting in lower maintenance costs.
- **Portability**: Docker runs on any platform.
- **Open Source**: Docker is open source, with an active community and a wealth of available images.
- **Security**: Docker uses sandboxing, enhancing security by isolating containers.
- **Rich Ecosystem**: Docker has a rich ecosystem with numerous tools.
- **Continuous Integration**: Docker integrates well with continuous integration tools.
- **Scalability**: Docker can quickly scale up or down based on demand.

:::

### Common Docker Commands

| Description | Command |
| :--------------------- | ---------------------------------------- |
| View Docker Version | `docker --version` |
| View Docker Info | `docker info` |
| View Docker Images | `docker images` |
| View Docker Containers | `docker ps` or `docker ps -a` |
| Pull Image | `docker pull image_name` |
| Run Container | `docker run -it image_name` |
| Start Container | `docker start container_id` |
| Stop Container | `docker stop container_id` |
| Restart Container | `docker restart container_id` |
| Enter Container | `docker exec -it container_id /bin/bash` |
| Remove Container | `docker rm container_id` |
| Remove Image | `docker rmi image_id` |
| View Container Logs | `docker logs -f container_id` |
1 change: 1 addition & 0 deletions src/en/guide/devtools/Git/1-git.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
order: 1
title: Git
icon: bx:bx-git-branch
---

::: tip
Expand Down
1 change: 1 addition & 0 deletions src/en/guide/devtools/IDE/1-goland.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
order: 1
title: Goland
icon: devicon-plain:goland
---

## Goland
Expand Down
1 change: 1 addition & 0 deletions src/en/guide/devtools/IDE/2-vscode.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
order: 2
title: VsCode
icon: akar-icons:vscode-fill
---

## VsCode
Expand Down
52 changes: 52 additions & 0 deletions src/guide/devtools/Docker/1-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
order: 1
title: Docker
icon: mdi:docker
---

## Docker 介绍

Docker 是一个开源的应用容器引擎,基于 Go 语言并遵从 Apache2.0 协议开源。Docker 可以让开发者打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口,与虚拟机相似,但是占用资源更少。一台主机一般只能运行几十台虚拟机,但是可以同时运行几百上千个容器。

::: info 什么是容器?(Container)
容器就是将应用程序及其依赖,打包在一个文件系统中,包含了一切运行所需的东西,如代码、运行时、系统工具、系统库等,保证应用在任何环境下都能运行。容器是独立于平台的,可以在开发环境、测试环境、生产环境中运行。
:::

### 为什么使用 Docker?

在没有容器之前,开发人员在开发环境中编写代码,然后将代码部署到测试环境,最后再部署到生产环境。这种方式存在很多问题,如环境不一致、部署麻烦、开发环境和生产环境不一致等。Docker 的出现解决了这些问题,使得开发、测试、生产环境一致,提高了开发效率。

::: info Docker 的优势

- **快速交付**:Docker 可以快速部署,可以在几秒或者几十秒内启动或停止容器。
- **一致运行环境**:Docker 可以保证开发环境、测试环境、生产环境一致。
- **高效利用系统资源**:Docker 可以在一台主机上运行多个容器,提高资源利用率。
- **轻量级**:Docker 利用容器共享主机内核,不需要运行完整的操作系统,因此比虚拟机更轻量级。
- **易于维护**:Docker 可以快速部署、快速启动、快速停止,维护成本低。
- **可移植性**:Docker 可以在任何平台上运行。
- **开源**:Docker 是开源的,社区活跃,有大量的镜像可以使用。
- **安全**:Docker 使用沙箱机制,相互之间不会有任何接口,提高了安全性。
- **生态丰富**:Docker 生态丰富,有大量的工具可以使用。
- **持续集成**:Docker 可以与持续集成工具结合,实现持续集成。
- **快速扩展**:Docker 可以快速扩展,可以根据需求快速增加或减少容器。

:::

### 常用 Docker 命令

| 描述 | 命令 |
| :--------------- | :--------------------------------- |
| 查看 Docker 版本 | `docker --version` |
| 查看 Docker 信息 | `docker info` |
| 查看 Docker 镜像 | `docker images` |
| 查看 Docker 容器 | `docker ps``docker ps -a` |
| 拉取镜像 | `docker pull 镜像名称` |
| 运行容器 | `docker run -it 镜像名称` |
| 启动容器 | `docker start 容器ID` |
| 停止容器 | `docker stop 容器ID` |
| 重启容器 | `docker restart 容器ID` |
| 进入容器 | `docker exec -it 容器ID /bin/bash` |
| 删除容器 | `docker rm 容器ID` |
| 删除镜像 | `docker rmi 镜像ID` |
| 查看容器日志 | `docker logs -f 容器ID` |

1 change: 1 addition & 0 deletions src/guide/devtools/Git/1-git.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
order: 1
title: Git
icon: bx:bx-git-branch
---

::: tip
Expand Down
1 change: 1 addition & 0 deletions src/guide/devtools/IDE/1-goland.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
order: 1
title: Goland
icon: devicon-plain:goland
---

## Goland
Expand Down
1 change: 1 addition & 0 deletions src/guide/devtools/IDE/2-vscode.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
order: 2
title: VsCode
icon: akar-icons:vscode-fill
---

## VsCode
Expand Down

0 comments on commit 353adf8

Please sign in to comment.