Docker linux versions [duplicate] - docker

This question already has answers here:
$(uname -a) returning the same in docker host or any docker container
(2 answers)
Closed 1 year ago.
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?

/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.

Related

Is there any difference to run docker command between in wsl mode and cmd mode?

I am new to docker.
I installed wsland running wsl2 (with Ubuntu) in windows 11 and Docker Desktop to play with docker.
I am curious if there is any difference to run docker command such as docker build between in cmd or in wsl mode?
wsl mode means: I enter wsl before running anything in the cmd.
Hope my question is clear.
If you've installed native Docker packages inside Ubuntu (e.g. with apt) then Docker is unavailable in the Windows host so you can't even run commands from there.
If you've installed Docker Desktop on Windows (the recommended setup) then you're effectively getting integration between both OSes so it doesn't really matter which environment you use. In fact the Linux binaries are wrappers provided by the bundle:
$ ls -al $(which docker)
lrwxrwxrwx 1 root root 48 Aug 23 10:40 /usr/bin/docker -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker

View installed packages in a docker container [duplicate]

This question already has an answer here:
Is there any way by which we can list out all the dependencies or libraries installed in running docker container?
(1 answer)
Closed 2 years ago.
There are containers raised in Docker. Containers run applications such as nginx, apache, etc.
How can I list the installed versions of those applications in each container?
Use the command docker container inspect <container-id>
$ docker container inspect --format '{{.Config.Env}}' cfa
[PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NGINX_VERSION=1.17.7 NJS_VERSION=0.3.7 PKG_RELEASE=1~buster]
What do you want? Check all versions? List all packages?
Type this inside container shell to check nginx/apache version:
$ nginx -v #=> Nginx
$ httpd -v #=> Apache
To connect to container bash (for example alpine):
$ docker container run -it alpine /bin/sh

Creating container image of old Centos

I need to create Centos 6.9 32bit system image. I found manual how to do that which contains link to script.
I suppose for this reason I need to run Centos 6.9 32bit, install docker in it and then run script.
Trying to install docker in Centos 6.9 and. Found that it is not possible to install on this system according to requarements in manual:
OS requirements
To install Docker CE, you need a maintained version of CentOS 7
How to create container for of old Centos 6.9 ?
There is already an official CentOS 6 32-bit image in Docker Hub, so you might not need to create your own. It can run on an x64 host.
There is no centos:6.9 tag but a quick test of the centos:6 tag shows that it is 6.9 anyway:
$ docker pull i386/centos:6
6: Pulling from i386/centos
6fe27d5f397b: Pull complete
Digest: sha256:af47b24bee01b29f3c86e484b716651f89c93d8ca73d88c1a74019c691e0d1e2
Status: Downloaded newer image for i386/centos:6
$ docker run -it i386/centos:6 bash
[root#508467e5637e /]# cat /etc/redhat-release
CentOS release 6.9 (Final)
Update
I see from your previous question that you had already found the official 32-bit CentOS 6 image but want it to run on a 32-bit host kernel.
According to the docker installation prerequisites, it needs a 64-bit host. Docker does have 32-bit packages but they only contain the docker client and not the daemon.
If you want to run a 32-bit version of the docker-daemon, you could try following this blog post which describes how to build it from source.

Unable to pull ubuntu image using docker on windows host

I have installed docker on windows 10.
Docker version:
Docker version 17.09.0-ce, build afdb6d4
I tried to pull latest ubuntu and ubuntu:16.04 using the bellow two commands
docker pull ubuntu
docker pull ubuntu:16.04
But I am getting the below error.
docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
no matching manifest for windows/amd64 in the manifest list entries
So is there any way to fix this issue?
You can't run linux images with a windows daemon.
If you are running Docker for Windows, it gives you the ability to switch between running a Windows Docker daemon and a Linux Docker daemon inside a hyper-v VM.
To run Linux workloads, make sure you have chosen "Switch to Linux Containers" in the Docker for Windows whale icon menu.
please follow the Docker tutorial here
In this case the problem is it requires adding the --experimental flag when starting dockerd.exe.

Docker exec runs command on host machine instead of container

I have docker (Docker version 1.3.1, build 4e9bbfa) running on virtual machine.
I have created some containers that has supervisor running to allow sshd and apache running.
Right now in order to do some changed i have to log in to ssh and run sh script, I tried exec command, but it seems not working on that server.
What i did to examine a problem: created file named host.txt in root (/) folder of host (where docker daemon is running) and executed
docker exec {container name} ls /
and it gave me list where host.txt present (Not that I have not mounted / into containers / (i even dont know if its possible))
I made exact same container on exact same docker version and executed same test on my ubuntu 14.04 machine, and it works as expected (no host.txt in list)
Any ideas why this might be happening?
I found what caused the issue
kernel < 3.8 is not supported
https://github.com/docker/docker/issues/8976
So for example on following machine it will not work:
uname -a
Linux VIR005-M033-APP 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux

Resources