如何通过kubernetes pod传递docker运行标志 [英] How to pass docker run flags via kubernetes pod
本文介绍了如何通过kubernetes pod传递docker运行标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在运行kubernetes集群,并在其中运行mailhog容器.
Hi I am running kubernetes cluster where I run mailhog container.
但是我需要使用自己的docker run参数运行它.如果我直接在docker中运行它.我会使用命令:
But I need to run it with own docker run parameter. If I would run it in docker directly. I would use command:
docker run mailhog/mailhog -auth-file=./auth.file
但是我需要通过Kubernetes pod运行它.我的吊舱看起来像:
But I need to run it via Kubernetes pod. My pod looks like:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mailhog
spec:
replicas: 1
revisionHistoryLimit: 1
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: mailhog
spec:
containers:
- name: mailhog
image: us.gcr.io/com/mailhog:1.0.0
ports:
- containerPort: 8025
如何通过kubernetes实现使用参数-auth-file =./auth.file运行Docker容器.谢谢.
How to achieve to run Docker container with parameter -auth-file=./auth.file via kubernetes. Thanks.
我尝试在containers
command: ["-auth-file", "/data/mailhog/auth.file"]
但是我得到
Failed to start container with docker id 7565654 with error: Error response from daemon: Container command '-auth-file' not found or does not exist.
推荐答案
感谢@ lang2
这是我的deployment.yaml:
here is my deployment.yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mailhog
spec:
replicas: 1
revisionHistoryLimit: 1
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: mailhog
spec:
volumes:
- name: secrets-volume
secret:
secretName: mailhog-login
containers:
- name: mailhog
image: us.gcr.io/com/mailhog:1.0.0
resources:
limits:
cpu: 70m
memory: 30Mi
requests:
cpu: 50m
memory: 20Mi
volumeMounts:
- name: secrets-volume
mountPath: /data/mailhog
readOnly: true
ports:
- containerPort: 8025
- containerPort: 1025
args:
- "-auth-file=/data/mailhog/auth.file"
这篇关于如何通过kubernetes pod传递docker运行标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文