Am I running on container or not? Am I running on container or not? kubernetes kubernetes

Am I running on container or not?


TLDR

if you are inside a container, you will see a .dockerenv file on the root.(thats why i suspect google cloud shell to be one).

to determine the os you can run cat /etc/os-relese;

EDIT

if it is container what is its base image?

it seems like this thing varies from cloud provider to another, so you will have to do the digging yourself every time.

ive just done mine, here are the results:

exploring google cloudshell base image:

  • i did cat /etc/hostname to get the container id, and got this:

    cs-6000-devshell-vm-41dc38ac-9af5-42e2-9ee5-b6f9d042decb

    which may provide a clue about some source devshell image

  • so i went for a Dockerfile: sudo find / -type f -name Dockerfile

and one of the results was:

/google/devshell/customimageskeleton/Dockerfile

which looked quite appropriate to me. so i cat /google/devshell/customimageskeleton/Dockerfile

and got

FROM gcr.io/cloudshell-images/cloudshell:latest# Add your content here# To trigger a rebuild of your Cloud Shell image:# 1. Commit your changes locally: git commit -a# 2. Push your changes upstream: git push origin master# This triggers a rebuild of your image hosted at GCR_REPO_URL.# You can find the Cloud Source Repository hosting this file at CSR_FILE_URL

a quick googling on the gcr.io/cloudshell-images/cloudshell:latest led me right into the image repo in google cloud registry

as you can see there, the image size is quite huge so i couldnt pull it anywhere, but if that bothers you, you can

docker pull gcr.io/cloudshell-images/cloudshell:latest

and then

docker history --no-trunc gcr.io/cloudshell-images/cloudshell:latest

to view the base Dockerfile.

hope that can help somebody somehow.


All containers certified by Jelastic are based on Centos OS v.7, with the exception of the image with Ubuntu VPS. In order to check the version Linux OS, you need to run commands:

For example:

for containers based on Centos OS:

$ cat /etc/os-release

NAME="CentOS Linux"

VERSION="7 (Core)"

ID="centos"

ID_LIKE="rhel fedora"

VERSION_ID="7"

PRETTY_NAME="CentOS Linux 7 (Core)"

ANSI_COLOR="0;31"

CPE_NAME="cpe:/o:centos:centos:7"

HOME_URL="https://www.centos.org/"

BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"

CENTOS_MANTISBT_PROJECT_VERSION="7"

REDHAT_SUPPORT_PRODUCT="centos"

REDHAT_SUPPORT_PRODUCT_VERSION="7"


for containers based on Debian OS:

# cat /etc/os-release

NAME="Ubuntu"

VERSION="18.04.2 LTS (Bionic Beaver)"

ID=ubuntu

ID_LIKE=debian

PRETTY_NAME="Ubuntu 18.04.2 LTS"

VERSION_ID="18.04"

HOME_URL="https://www.ubuntu.com/"

SUPPORT_URL="https://help.ubuntu.com/"

BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"

PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"

VERSION_CODENAME=bionic

UBUNTU_CODENAME=bionic

# lsb_release -a

No LSB modules are available.

Distributor ID:Ubuntu

Description:Ubuntu 18.04.2 LTS

Release:18.04

Codename:bionic