0

I am creating a very basic image on my debian wheezy host machine. This is the Dockerfile:

FROM ubuntu:trusty
USER root

# Activate multiverse repos
RUN echo 'deb http://archive.ubuntu.com/ubuntu/ trusty universe multiverse' >> /etc/apt/sources.list
RUN echo 'deb http://security.ubuntu.com/ubuntu trusty-security universe multiverse' >> /etc/apt/sources.list
RUN echo 'deb http://archive.ubuntu.com/ubuntu/ trusty-updates universe multiverse' >> /etc/apt/sources.list
RUN apt-get update

RUN apt-get install -y supervisor

WORKDIR /

CMD ["/usr/bin/supervisord", "-n"]

To build the image, I used docker build -t basic-ubuntu .

To run the container, I used docker run -d basic-ubuntu

To go into the container, I used docker exec -i -t <container_id> bash

When I am into the container, what I see is that the container's root directory / has the same content as the host. When I create a file on the container, it's also created on the host. Even when I add in the Dockerfile a RUN apt-get install -y of some package I don't have on the host, then I don't find it on the container. Actually even the $PATH variable on the container is the same as the host.

Here are some info on my env

host$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 7.8 (wheezy)
Release:        7.8
Codename:       wheezy

host$ docker version
Client:
 Version:      1.10.1
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   9e83765
 Built:        Thu Feb 11 19:20:12 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.1
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   9e83765
 Built:        Thu Feb 11 19:20:12 2016
 OS/Arch:      linux/amd64

The mounts shown by docker inspect

"Mounts": []

For the full docker inspect trace: http://pastebin.com/t4uSu4ZH

I think that the problem comes from the docker exec step. Because the build and run seem to work correctly.

amine
  • 502
  • 5
  • 14

2 Answers2

1

I think that the problem comes from the docker exec step

That is certainly the case, considering a container is there to isolate you from the host.
(different filesystem, process, root, user, ...)

When you "exec bash" to a container, you should see a prompt:

 root@<short_container_id>

If you don't see that, it is because somehow your docker exec did not execute properly.

If you do see that, then what you think is on the host is actually still the container content.

Also relevant, there is a potential bug around -i (interactive) when used with docker exec.
See "Why do there exist “-i” and “-t” options for the “docker exec” command?".

The OP amine confirms it is the case in the comments:

Issue 8755 ("Docker tty is not a tty with docker exec") means -t (tty) does not correctly opens a tty on centos7 (not centos6).

This happens even if TERM is set to xterm (don't forget issue 9299: docker exec does not set TERM env when -t passed)


The other issue mentioned by the Op is:

When I went back to the howto install docker in debian, I found that in the prerequisites: "kernel must be 3.10 at minimum" and "These older versions are known to have bugs".
And my debian's kernel version is 3.2.
The solution was to upgrade to a newer debian version, with a kernel version above 3.10.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • No I don't have that problem: `myuser@myhostname$ docker exec -i -t 151961654ce5467cff51c606d6e9886c01008c4a9a81c0076715dfca77318f73 bash` `root@151961654ce5:/#` – amine Feb 27 '16 at 17:12
  • And creating a file there creates it on your host too? Since you have not mounted a volume (https://docs.docker.com/engine/userguide/containers/dockervolumes/#mount-a-host-file-as-a-data-volume), that is unlikely. – VonC Feb 27 '16 at 17:13
  • Yes that happens and it's totally weird I agree – amine Feb 27 '16 at 17:14
  • @amine Are you *sure* though? How do you check that the file exist on the host, and not just on the container? – VonC Feb 27 '16 at 17:14
  • `root@151961654ce5:/# echo "foo" > bar.txt` `root@151961654ce5:/# exit` `myuser@myhostname$ cd / && cat bar.txt` `foo` – amine Feb 27 '16 at 17:17
  • @amine ok, the CMD supervisord must be the weird element there. Can you rebuild the image with a simpler `CMD [ "while true; do sleep 1; done" ]`? – VonC Feb 27 '16 at 17:21
  • when running, it lead to `docker: Error response from daemon: Container command not found or does not exist..` and the container's status is `Created` – amine Feb 27 '16 at 17:32
  • @amine OK. Can you simply remove the CMD from the Dockerfile, rebuild it, and try a `docker run -it --rm bash`. In that session, create a file, and in another shell, see if that file appears on your host. – VonC Feb 27 '16 at 17:35
  • that worked fine. it's different from the host's content – amine Feb 27 '16 at 17:38
  • @amine At least, that is finally what I expected. Now why the daemonize version of your container *seems* to behave strangely? – VonC Feb 27 '16 at 17:39
  • @amine can you try again, with no CMD, and a `docker run -d sh -c "while true; do sleep 1; done"` – VonC Feb 27 '16 at 17:40
  • the container starts but when using `docker exec -i -t bash` same problem as always, host's content shows in container – amine Feb 27 '16 at 17:44
  • @amine can you try again, this time (after killing the container) adding the -i option: `docker run -id sh -c "while true; do sleep 1; done"`. Also, if the issue persists, that could be because of http://stackoverflow.com/a/35551071/6309 – VonC Feb 27 '16 at 17:46
  • same. nothing changed – amine Feb 27 '16 at 17:48
  • @amine Then issue https://github.com/docker/docker/issues/8755 could be at play here. – VonC Feb 27 '16 at 17:50
  • yes this seems to be the same issue. I have another host machine running ubuntu (and another version of docker I think). I will run the image on it and see if it reproduces – amine Feb 27 '16 at 17:59
  • tested on a ubuntu trusty with docker 1.10.2 and it works without any bug. @VonC please update your reply with the github issue link and thanks a lot for your help – amine Feb 28 '16 at 00:52
  • FYI when I went back to the howto install docker in debian https://docs.docker.com/engine/installation/linux/debian, I found that in the prerequisites: "kernel must be 3.10 at minimum" and "These older versions are known to have bugs". And my debian's kernel version is 3.2. The solution was to upgrade to a newer debian version, with a kernel version above 3.10. And this is the procedure I followed https://linuxconfig.org/how-to-upgrade-debian-linux-system-from-wheezy-to-jessie-stable-release I hope that could help people having this kind of issue – amine Feb 29 '16 at 07:16
  • 1
    @amine Great! I have included your comment in the answer for more visibility. – VonC Feb 29 '16 at 07:28
0

I met the same issue where docker volume mount function was not working correctly . And this turned out to be the kernel version issue. After I upgrade my Debian kernel from 3.2 up to 3.16, everything works fine.

$ uname -a
Linux 3.16.0-0.bpo.4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u3~bpo70+1 (2016-01-19) x86_64 GNU/Linux
mainframer
  • 20,411
  • 12
  • 49
  • 68