Skip to content

Commit

Permalink
doc(devbox): add fqa in devbox doc (#5289)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbluebird authored Dec 19, 2024
1 parent 095ac52 commit 95ed066
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 2 deletions.
74 changes: 73 additions & 1 deletion docs/5.0/docs/user-guide/devbox/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,76 @@ Try to open Cursor's extension market. If the extension market cannot be loaded

## 6. The local localhost can open the project but the public network address cannot be opened

The exposed address in the code must be changed from `localhost` to `0.0.0.0` due to network reasons.
The exposed address in the code must be changed from `localhost` to `0.0.0.0` due to network reasons.

## 7. The Program Runs Normally in Devbox, but Fails to Run After Deployment

Before deploying, please ensure you can execute `entrypoint.sh` in the terminal (this is the recommended startup script
post-deployment). If public services are required, also check that the public address is accessible.

```bash
./entrypoint.sh
```

If you encounter the following issue:

```bash
bash: ./entrypoint.sh: Permission denied
```

You can run the following command in the terminal to modify the script's permissions, and then attempt to execute the
`entrypoint` script again, ensuring the outcome aligns with your expectations.

```bash
sudo chmod +x entrypoint.sh
```

Additionally, it is advisable to build and test the project code in Devbox before deployment. Once testing is
successful, you can proceed with the deployment. This can effectively prevent errors and out-of-memory (OOM) issues
during the startup phase after deployment.

## 8. Application Startup Fails When Listening on Port 80

When using Devbox, the default user for local editors (such as VSCode, Cursor, etc.) is devbox.
Ports in the range of 1-1023 are restricted to the administrator user.
If you need to use these ports normally, please run your program with administrator privileges. For example, in the Go
Devbox, you can use the following command:

```bash
sudo go run main.go
```

Alternatively, you could change your application's port.

## 9. How to Change the Default User to Root in Devbox

If you want to connect to Devbox as the root user when opening a local editor, please follow these steps. First, ensure
your Devbox can connect properly using the default configuration. Open the file `~/.ssh/sealos/devbox_config` on your
local machine. If you are uncertain about the file's location, please refer to Question 2.

Locate the configuration that you wish to modify to use the root user, for example:

```config
Host usw.sailos.io_ns-rqtny6y6_devbox1234
HostName usw.sailos.io
User devbox
Port 40911
IdentityFile ~/.ssh/sealos/usw.sailos.io_ns-rqtny6y6_devbox1234
IdentitiesOnly yes
StrictHostKeyChecking no
```

Change the `User` value to root, as follows:

```config
Host usw.sailos.io_ns-rqtny6y6_devbox1234
HostName usw.sailos.io
User root
Port 40911
IdentityFile ~/.ssh/sealos/usw.sailos.io_ns-rqtny6y6_devbox1234
IdentitiesOnly yes
StrictHostKeyChecking no
```

After saving the changes, exit the local editor connected to Devbox and then reopen the editor. You should now be
connected to Devbox as the root user.
68 changes: 67 additions & 1 deletion docs/5.0/i18n/zh-Hans/user-guide/devbox/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,70 @@ upstream connect error or disconnect/reset before headers. retried and the lates

## 6、本地 localhost 能打开项目但是公网地址打不开

代码里暴露地址由于网络原因必须从 `localhost` 改为 `0.0.0.0`
代码里暴露地址由于网络原因必须从 `localhost` 改为 `0.0.0.0`

## 7、在 Devbox 中可以正常运行程序,但是在发版之后,程序无法正常运行

在发版之前请确保能在终端中运行 `entrypoint.sh` (这是推荐的发版后的启动脚本),如果需要公网服务,也请同时检查公网地址是否联通。

```bash
./entrypoint.sh
```

如果遇到下面的问题:

```bash
bash: ./entrypoint.sh: Permission denied
```

可以在终端中输入如下的命令,并再次运行 `entrypoint` 脚本,并确保结果与期望的相同。

```bash
sudo chmod +x entrypoint.sh
```

同时,建议先在 Devbox 中预先构建完项目代码后并测试,测试成功后再发版,这可以有效避免在发版后的启动时的错误和 oom 问题。

## 8、应用程序监听的端口为 80 时,应用程序启动失败

在使用 Devbox 时,本地编辑器(vscode、cursor 等)
默认的用户为 Devbox,监听 1-1023 端口是管理员用户的特权。 如果需要正常使用,请使用管理员账户运行你的程序,例如在 go 的
Devbox 中,可以使用下面的命令:

```bash
sudo go run main.go
```

或者变更你的端口。

## 9、如何在 Devbox 中更换默认的用户为 root 用户

如果你需要在打开本地编辑器时,链接到 Devbox 的用户为 root,可以参考以下的步骤。
首先请确保你的 Devbox 在使用默认的配置时,可以正常连接。
打开本地电脑的 `~/.ssh/sealos/devbox_config`,如果不清楚这个文件在哪里,请参考问题2。

找到你需要切换为 root 用户的配置,例如:

```config
Host usw.sailos.io_ns-rqtny6y6_devbox1234
HostName usw.sailos.io
User devbox
Port 40911
IdentityFile ~/.ssh/sealos/usw.sailos.io_ns-rqtny6y6_devbox1234
IdentitiesOnly yes
StrictHostKeyChecking no
```

修改 `User` 的值为 root,例如:

```config
Host usw.sailos.io_ns-rqtny6y6_devbox1234
HostName usw.sailos.io
User root
Port 40911
IdentityFile ~/.ssh/sealos/usw.sailos.io_ns-rqtny6y6_devbox1234
IdentitiesOnly yes
StrictHostKeyChecking no
```

保存之后退出打开了 Devbox 的本地编辑器,重新打开编辑器,连接到 Devbox,此时的用户已经切换为 root。

0 comments on commit 95ed066

Please sign in to comment.