Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add /run/.containerenv file #5461

@pjbgf

Description

@pjbgf

Description

I have an use case in which I need my application to quickly identify whether or not it is running inside of a container.
Both Podman and Docker enables this by creating a file (/run/.containerenv and /.dockerenv respectively) in their containers.

Can we add /run/.containerenv into CRI-O containers to enable this use case too?

Reference to how docker handles it: #2036 (comment)

Steps to reproduce the issue:

  1. Create a container/pod
  2. stat /run/.containerenv

Describe the results you received:

stat: cannot stat '/run/.containerenv': No such file or directory

Describe the results you expected:

The details of the file

/ # stat /run/.containerenv
  File: /run/.containerenv
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 36h/54d Inode: 56758596    Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-11-15 18:24:21.935100421 +0000
Modify: 2021-11-15 18:24:21.935100421 +0000
Change: 2021-11-15 18:24:21.935100421 +0000

Additional information you deem important (e.g. issue happens only occasionally):

N/A

Output of crio --version:

INFO[0000] Starting CRI-O, version: 1.20.6, git: 0ff8c357921afde70b4f11156adc719085e27da4(clean)
crio version 1.20.6
Version:       1.20.6
GitCommit:     0ff8c357921afde70b4f11156adc719085e27da4
GitTreeState:  clean
BuildDate:     2021-11-11T20:04:40Z
GoVersion:     go1.15.2
Compiler:      gc
Platform:      linux/amd64
Linkmode:      dynamic

Additional environment details (AWS, VirtualBox, physical, etc.):

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions