Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

265
Vistas
Why java requires base image to run on docker

I'm trying to understand why can't I run java inside docker container without having a base OS image.
I tried the next basic dockerfile:

FROM scratch

ADD openjdk-11.0.2_linux-x64_bin.tar.gz /java

CMD ["/java/jdk-11.0.2/bin/java", "-version" ]

And got the following error:

standard_init_linux.go:207: exec user process caused "no such file or directory"

In my understanding that's probably has something to do with unmet dependencies, but I still don't understand why I need all the user-space file system that comes with base images just to run a binary executable. aren't they supposed to run natively? what's the difference between binary that's able to run standalone and one that doesn't?

In addition I'm interested to know what is that file standard_init_linux.go? does the linux kernel contains go code?

I've found some resources about base images (below), but they still doesn't provide direct answer for my question.

Resources

  • Docker: base image
  • Architecting Containers Part 1: Why Understanding User Space vs. Kernel Space Matters
  • What is the relationship between the docker host OS and the container base image OS?
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

The binary has shared library dependencies. If those dependencies aren't in the system, it won't run.

As you said, it's hard to inspect the image directly, but you can take a look at the executable on your host system. Here's what it looks like on mine:

$ ldd java/jdk-11.0.2/bin/java
    linux-vdso.so.1 (0x00007ffc16fac000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd839c97000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd839a78000)
    libjli.so => /home/jkugelman/from-scratch-java/java/jdk-11.0.2/bin/../lib/jli/libjli.so (0x00007fd839867000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd839663000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd839272000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fd839eb4000)

Mounting /lib and /lib64 gets it to run:

$ docker run --rm -it -v /lib:/lib -v /lib64:/lib64 from-scratch-java
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
over 4 years ago · Santiago Trujillo Denunciar

0

Shared libraries.

Executables that aren't statically linked need a linker, a loader, and shared libraries (like the standard C library) that they link against. That's provided by your OS image.

over 4 years ago · Santiago Trujillo Denunciar

0

Java/JVM is really just another executable program like 'apache' or 'top'. like all programs it needs an operating system host to manage the hardware and provide standardized interfaces. The binary code of Java is compiled against specific OS's and Kernels.

More fundamentally, I am curious if Docker container would run without a base OS image. The container should use the host Kernel, but it should still require a base OS image on top of the kernel.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda