How to pass the Docker CLI Arguments when starting a container using Kubernetes

4/28/2017

I am exploring Kubernetes Cluster orchestration and I am familiar with docker based containerization techniques.

Normally when starting docker containers, we pass different CLI Arguments(port options + Env variables) something like below

docker run --name myService -p 8080:8080  -v /var/lib/otds:/usr/local/otds  -e VIRTUAL_PORT=8080 myImage

When I am trying to up the same on Kubernetes Cluster(using its CLI - kuberctl) I am seeing errors saying that these arguments are not recognized

I am trying something like below

kuberctl run myService -p 8080:8080  -v /var/lib/otds:/usr/local/otds  -e VIRTUAL_PORT=8080 --image==myImage

I am looking for help on how to pass docker's CLI Arguments to KuberCTL

-- AdityaReddy
containers
docker
kubernetes

1 Answer

4/28/2017

kubectl run is just a shorthand convenience method. Normally you should be writing pod specs in YAML/JSON.

Based on your unfamiliarity with basics, I would highly recommend sitting down and following through some of the training material at https://kubernetes.io/docs/tutorials/

As for your question, in a pod spec, the command/args field is what you're looking for and it is documented here: https://kubernetes.io/docs/tasks/configure-pod-container/define-command-argument-container/

Here's a sample:

apiVersion: v1
kind: Pod
metadata:
  name: demo
spec:
  containers:
  - name: foo
    image: alpine
    command: ["date"]
-- AhmetB - Google
Source: StackOverflow