forked from Websoft9/doc.websoft9.com
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e74053e
commit ab1ce9c
Showing
20 changed files
with
252 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
i18n/en/docusaurus-plugin-content-docs/current/guide/container/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import DocCardList from '@theme/DocCardList'; | ||
import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; | ||
|
||
# 使用和管理容器 | ||
# Manage and set container | ||
|
||
容器技术是 Websoft9 多应用托管平台的核心基础架构组件。因此,在管理应用时,您可能需要执行容器相关的操作。 | ||
Container technology is the core infrastructure of Websoft9's multi-application hosting platform. | ||
|
||
## 相关指南 | ||
## Tutorials | ||
|
||
<DocCardList items={useCurrentSidebarCategory().items}/> | ||
|
||
## 容器引擎 | ||
## Container engines | ||
|
||
- [Docker](https://www.docker.com/) | ||
- [Podman](https://podman.io/) |
Binary file added
BIN
+23.7 KB
...ugin-content-docs/current/guide/container/assets/websoft9-container-console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+137 KB
...urus-plugin-content-docs/current/guide/container/assets/websoft9-containers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+12.4 KB
(130%)
...content-docs/current/guide/container/assets/websoft9-myapps-runcmd-websoft9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-77.9 KB
...aurus-plugin-content-docs/current/guide/container/assets/websoft9-portainer.png
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 55 additions & 36 deletions
91
i18n/en/docusaurus-plugin-content-docs/current/guide/container/inner-container.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,83 @@ | ||
--- | ||
sidebar_position: 1 | ||
title: Run commands in container | ||
slug: /inner-container | ||
--- | ||
|
||
# 在容器内运行命令 | ||
# Run commands in the container | ||
|
||
用户需要掌握在容器内运行命令的操作,便于更好的实现个性化的托管设置。 | ||
When managing Docker containers, you may need to connect to a running container. It is very helpful if you want to see what is happening inside the container. You can use the [docker exec](https://docs.docker.com/reference/cli/docker/container/exec/) command, SSH into a running Docker container, or get a shell to the container. | ||
|
||
## 原理 | ||
## Concepts | ||
|
||
在容器内运行命令之前,先列出几个相关的原理: | ||
Before running commands inside a container, let's list a few related concepts: | ||
|
||
- 容器内运行命令与 Linux 虚拟机内运行命令的原理基本一致 | ||
- 容器内运行命令改变的是容器的文件系统 | ||
- 容器内也可以切换用户 | ||
- 容器内改变文件系统后,也需要考虑权限问题 | ||
- 容器内安装或下载的软件包,若没有存放到持久化目录中,重建容器后这些增加的文件会丢失 | ||
- Running commands in containers is similar to host machine. | ||
- Commands in containers alter the container's filesystem. | ||
- You can change the user account within containers. | ||
- Filesystem changes in containers require permission considerations. | ||
- Software installed in non-persistent directories will be lost after redeploy. | ||
|
||
## 进入容器{#docker-exec} | ||
## Method of access to containers{#docker-exec} | ||
|
||
进入容器后,默认便可以运行 shell 命令。有两种进入容器的方法: | ||
Two methods for you to access container: | ||
|
||
### 登录服务器运行命令{#fromserver} | ||
### Access by docker exec commands{#fromserver} | ||
|
||
Docker 自身提供了进入了容器的操作指令 [docker exec](https://docs.docker.com/reference/cli/docker/container/exec/) ,具体步骤: | ||
The `docker exec` command runs a new command in a running container at your host machine. | ||
|
||
- 确认容器的 shell 命令环境: bash, sh, ash 三者之一,大部分都是 bash | ||
- 服务器端运行 `docker ps` 找到容器名称,然后运行命令 `docker exec -it container_name bash` | ||
``` | ||
# sample1 | ||
docker exec -it container_name bash | ||
### 在线运行命令{#fromweb} | ||
# sample2 | ||
docker exec -it container_name sh | ||
Websoft9 提供了可视化的在线运行容器命令的功能,它是 **docker exec** 的 Web 实现。 | ||
# sample2 | ||
docker exec -it container_name ash | ||
1. Websoft9 控制台进入应用的详情页面,在 "容器" 标签页下点击 `<>` 操作 | ||
![](./assets/websoft9-myapps-runcmd-websoft9.png) | ||
# sample4 | ||
docker run --name mycontainer -d -i -t alpine /bin/sh | ||
``` | ||
|
||
You should know or try to get the shell environment of your container, it may `bash`, `sh`, or `ash` | ||
|
||
### Access container by Websoft9 Console{#fromweb} | ||
|
||
2. 在容器命令行控制台,点击 **Connetc** 按钮,开始连接 | ||
You can access container by Websoft9 Console which is the implementation of **docker exec** command. | ||
|
||
- Command:选择可用的命令执行(三选一,bash 绝大部分情况下都可用) | ||
- user: 默认 root(推荐) | ||
1. Login to Websoft9 Console, go to application mangement from **My Apps** | ||
|
||
2. Open the **Containers** tab, click `<>` icon of Actions column | ||
![](./assets/websoft9-myapps-runcmd-websoft9.png) | ||
|
||
3. 成功连接,即可开始运行命令 | ||
3. It will jump to the **Container console** and you can select the items and **Connect** container | ||
![](./assets/websoft9-container-console.png) | ||
|
||
4. Once connection success, you can run shell command from terminal | ||
![](./assets/websoft9-myapps-runcmdss-websoft9.png) | ||
|
||
## 安装软件包 | ||
|
||
容器内安装软件与 Linux 安装软件基本一致: | ||
## Commans samples | ||
|
||
### Install packages in the container | ||
|
||
Install packages in the container is the same with host machine: | ||
|
||
- Install by Linux repo tools: `apt`, `yum`, `dnf`, `pacman`, `zypper`, `apk` | ||
- Download and compile | ||
- Install by languages repo tools: `pip`, `npm`, `yarn`, `gem` | ||
|
||
- 操作系统包管理器:apt, yum, dnf, pacman, zypper, apk 等 | ||
- 手工下载编译安装 | ||
- 程序语言安装包:pip, npm, yarn, gem 等 | ||
### Check system settings in the container | ||
|
||
## 查看容器内配置 | ||
- Process and services: `top`, `ps aux` | ||
- Get users: `cat /etc/passwd` | ||
- Network: `netstat -tulnp`, `ss -tuln` | ||
|
||
- 进程与服务:`top`, `ps aux` | ||
- 用户:`cat /etc/passwd` | ||
- 网络:`netstat -tulnp`, `ss -tuln` | ||
## Troubleshoot | ||
|
||
## 权限处理 | ||
### Container permission issues? | ||
|
||
- 如果 Dockerfile 没有创建普通用户,容器就会默认以 root 用户权限运行。 | ||
- 容器 root 与宿主机 root 是同一个用户,但容器 root 需加上 `--privileged=true` 才拥有宿主机同等权限 | ||
- 容器内可以通过 `su` 切换用户 | ||
- If the dockerfile does not create non-root user, the container will run as root by default. | ||
- Container root equals host root, needs `--privileged=true` for same privileges. | ||
- You can switch users within the container using `su`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+8.68 KB
(110%)
...n-content-docs/current/guide/database/assets/websoft9-appstore-dbmanagelist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.