docker k8s 命令学习

暗香疏影 创作者

docker基础命令

1
2
3
docker run -d --name rocky8.10 --restart=always rockylinux/rockylinux:8.10.20240528-minimal /bin/bash -c "while true; do echo 1week-hello; sleep 604800; done"

docker run -d --name rocky8.10 --restart=always rockylinux/rockylinux:8.10 /bin/bash -c "while true; do sleep 30; done" --cpus=2 --memory=2g
1
docker run -d -p 10000:9000 --name v2ray --restart=always -v /opt/v2ray:/etc/v2ray teddysun/v2ray

前面端口10000是机器端口,容器内端口是9000
同理,映射存储将容器外机器的/opt/v2ray映射到容器内的/etc/v2ray

查看

1
2
docker ps
docker images

部分镜像没有curl 但是可以用wget来测试公网IP

1
2
3
curl 'https://api.ipify.org?format=json'

wget -qO- "ifconfig.me"

在线docker run命令转换yml

k8s基础命令

k8s Ubuntu安装教程
k8s Rocky Linux 安装教程

1
kubectl get pod
1
kubectl get pod -A -o wide

v2ray k8s

例子:ACS Alibaba Cloud
基础配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
apiVersion: apps/v1
kind: Deployment
metadata:
name: v2ray
labels:
app: v2ray
spec:
replicas: 1
selector:
matchLabels:
app: v2ray
template:
metadata:
name: v2ray
labels:
app: v2ray
alibabacloud.com/compute-class: general-purpose
alibabacloud.com/compute-qos: best-effort
spec:
nodeSelector:
type: virtual-kubelet
tolerations:
- key: "virtual-kubelet.io/provider"
operator: "Exists"
effect: "NoSchedule"
containers:
- name: v2ray
image: teddysun/v2ray:5.24.0
ports:
- containerPort: 9000
volumeMounts:
- name: v2-config-vol
mountPath: /etc/v2ray/
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 1
memory: 1Gi
volumes:
- configMap:
name: v2config
name: v2-config-vol

ConfigMap配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
apiVersion: v1
kind: ConfigMap
metadata:
name: v2config
namespace: default
data:
config.json: |+
{
"inbounds": [{
"port": 9000,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "3ceb7ffe-2ad4-fd7e-4656-1528327633b8",
"level": 1,
"alterId": 64
}
]
}
}],
"outbounds": [{
"protocol": "freedom",
"settings": {}
}]
}

  • 标题: docker k8s 命令学习
  • 作者: 暗香疏影
  • 创建于 : 2025-01-19 08:00:00
  • 更新于 : 2025-01-19 08:00:00
  • 链接: https://blog.23ikr.com/2025/01/19/Wiki-Guide/2025-01-19-container-docker-k8s/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
docker k8s 命令学习