0

I am learning docker basics. I created a simple image

FROM alpine
RUN apk add --update redis
CMD ["redis-server"]

I started the container and logged in using

docker exec -it c57389dc94f5 sh

From the shell prompt, if I execute

more   /etc/alpine-release

I get 3.14.2.

If I execute

more /proc/version

I get

Linux version 5.4.0-84-generic (buildd@lgw01-amd64-050) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021

Why am I getting Ubuntu when the image uses Alpine?

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
Jayadevan
  • 1,306
  • 2
  • 12
  • 33

1 Answers1

1

/cat/proc give you the version of the OS which hosts the docker container, and not the docker image version. Remember that docker is not a virtual machine, but a bunch of isolated processes, named container, running on top of the hosting OS (and so, by its own kernel).

I guess that you are using docker on Ubuntu. Is it right?

Please refer to official docker containers architecture.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
  • You are right. I am using Ubuntu. But once I am 'inside' a container, why is it getting the host info? – Jayadevan Sep 15 '21 at 08:58
  • 1
    As I explained, the docker executes container by the host kernel. I suggest you to go deeper into the docker architecture https://www.docker.com/resources/what-container . – Antonio Petricca Sep 15 '21 at 12:13