I am able to run following plain docker command and volumes are created and mapped.This is privileged container.
docker run -d --network host --name test_container --volume test_volume:/mnt --privileged -v /dev:/dev $IMAGE_NAME
This container should be deployed as POD in kubernetes.
I tried creating podspec for this and its failing with below error :
Message: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: "/mnt/somescript.sh": stat /mnt/somescript.sh: no such file or directory"
Below is the podspec snapshot:
spec:
automountServiceAccountToken: false
containers:
image: test_container:latest
imagePullPolicy: IfNotPresent
name: test-container
resources: {}
securityContext:
privileged: true
volumeMounts:
- mountPath: "/mnt"
name: testvolume
- mountPath: "/dev"
name: devdata
hostNetwork: true
hostname: test
imagePullSecrets:
- name: acr-pull
nodeName: xxxxxx
restartPolicy: Always
volumes:
- hostPath:
path: /mnt
type: Directory
name: testvolume
- hostPath:
path: /dev
type: Directory
name: devdata
Also volumes not getting created for /mnt and /dev dir of containers.