How to define the "docker container run" args in kubernetes

7/11/2019

My docker container run command line included a lot of args, for example:

docker container run --privileged --rm -u ${USER} -v $HOME:$HOME -e CURRENT_LOGLVL=$CURRENT_LOGLVL -it mydockerimg /bin/bash

reference for these args

--privileged      Give extended privileges to this container
I need to run in privilege mode to give extended privileges to this container

-v                 Bind mount a volume
I need to access a NFS mount point inside the docker container

-u                 Username or UID
I need to use special user

--rm            Automatically remove the container when it exits

-i      Keep STDIN open even if not attached

-e              environment variable

I read some docs like https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/ https://kubernetes.io/docs/concepts/storage/persistent-volumes/

Environment variable and volume related information can be found. But how to handle other args like --privileged and so on?

Is there some way to pass these args directly to docker? OR Is there anyway that I run the docker command line manually but K8S have some way to transfer the docker container instance into a POD?

Thanks for any tips or links

-- Evilight
docker
kubernetes

1 Answer

7/11/2019

For privileged container and -u need use secure context. Also in kubernetes, you can use --rm flag.

-- Arslanbekov
Source: StackOverflow