Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
XmchxUp committed Jul 5, 2024
1 parent c37c099 commit 3d16054
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
42 changes: 42 additions & 0 deletions 2024/07/docker_container_ip.md
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 ]
```

24 changes: 24 additions & 0 deletions 2024/07/docker_debug_tool.md
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`,大概率是文件传输后不完整的问题。
14 changes: 14 additions & 0 deletions 2024/07/server_cd.md
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

集群部署的选择
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ The best thing to do is have fun.
- [列表 - 韩立的修炼](/)
- [Hobby Projects](/hobby_projects.md)
- [Kata](/kata.md)

- **2024-07**
- [服务部署方案](/2024/07/server_cd.md)
- [docker sdk for python 获得容器ip地址](/2024/07/docker_container_ip.md)
- [容器调试工具](/2024/07/container_debug_tool.md)
- **2024-06**
- [写个 B+Tree](/2024/06/cmu15445_p2.md)
- [AWS/wireguard 测试](/2024/06/aws_wireguard.md)
Expand Down

0 comments on commit 3d16054

Please sign in to comment.