-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
85 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
```python | ||
def get_ips(): | ||
client = docker.from_env() | ||
containers = client.containers.list() | ||
# 打印所有容器的信息以及IP地址 | ||
ips = [] | ||
for container in containers: | ||
container.reload() | ||
container_name = container.name | ||
if not container_name.startswith("proxy-stablediffusion_sd_"): | ||
continue | ||
container_id = container.id | ||
# print(container.attrs) | ||
container_ip = container.attrs["NetworkSettings"]["Networks"][ | ||
"proxy-stablediffusion_default" | ||
]["IPAddress"] | ||
ips.append(container_ip) | ||
print(f"容器名称: {container_name}, 容器ID: {container_id}, 容器IP: {container_ip}") | ||
return ips | ||
``` | ||
|
||
|
||
```docker-compose | ||
version: '3.3' | ||
services: | ||
sd: | ||
#ports: | ||
# - '7860:7860' | ||
volumes: | ||
- './models:/webui/models/Stable-diffusion/' | ||
image: mirav.tencentcloudcr.com/mira/sd | ||
deploy: | ||
replicas: 6 | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: nvidia | ||
count: 1 | ||
capabilities: [ gpu ] | ||
``` | ||
|
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
## ctl/crictl | ||
|
||
## nsenter | ||
|
||
```sh | ||
nsenter -t <pid> -n <command> | ||
``` | ||
|
||
由于容器内部经常没有一些工具的安装如ping/tcpdump/netstat/nslookup/ip route等等,每个容器一个个安装起来非常麻烦, | ||
使用此工具则可以避免安装 | ||
|
||
pid查看一般容器ctl有提供inspect里面会有pid,如 | ||
|
||
```sh | ||
docker inspect xxx | grep -i pid | ||
|
||
crictl inspect xx | grep -i pid | ||
``` | ||
|
||
|
||
## image的copy | ||
|
||
使用ctl让image导出导入的时候,会出现`invalid tar header`,大概率是文件传输后不完整的问题。 |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
### Linux Systemd | ||
|
||
之前使用screen之前日志很麻烦,使用加上nohup后还行,但是重启还是需要杀掉再启两步。 | ||
|
||
编写个systemd service配置,然后就可以使用systemctl/journalctl了。 | ||
|
||
### Docker | ||
|
||
主要就是编写Dockerfile和docker-compose文件 | ||
|
||
### K8S | ||
|
||
集群部署的选择 |
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