Why I can not get the tail output of a file created by the docker assembly

Docker Information:

Containers: 18
 Running: 18
 Paused: 0
 Stopped: 0
Images: 188
Server Version: 1.13.1
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1
runc version: 9df8b306d01f59d3a8029be411de015b7304dd8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.0-1-amd64
Operating System: Debian GNU/Linux 9 (stretch)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.56 GiB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Experimental: false
Insecure Registries:
   127.0.0.0/8
Live Restore Enabled: false

Version for dockers: Docker version 1.13.1, build 092cba372

I have this docker file:

FROM debian:latest
RUN touch /var/log/mylog.log
CMD ["tail", "-F", "/var/log/mylog.log"]

Building it with docker build . -t test/testand running it with docker run -ti test/testwill cause the file to be output to stdout as follows (ignore the tail warning):

$ docker run --name test -t test/test
tail: unrecognized file system type 0x794c7630 for '/var/log/mylog.log'.   please report this to bug-coreutils@gnu.org. reverting to polling

The following command will be written to a file /var/log/mylog.log, followed by a file tail:

docker exec -ti test bash -c "echo 'asd' >> /var/log/mylog.log"

Unfortunately, there is no way out on another terminal, even if it catshows that the file contains content:

$ docker exec -ti test bash -c "cat /var/log/mylog.log"
asd

Although, if I create a file with PID1 instead of creating it inside the dockerfile, I get the contents of the file with the tail. I can also get the contents of the tail if I am docker stop test && docker start testwith earlier commands.

? - docker script live?

+4
2

, overlay2 Docker 4.9.8-moby Alpine.

, CMD tail /var/log/mylog.log , RUN touch /var/log/mylog.log.

, , , , . tail , -f -f.

docker start docker stop , tail /var/log/mylog.log "" . CMD :

CMD ["sh", "-c", "touch /var/log/mylog.log && tail -f /var/log/mylog.log"]

debian:testing coreutils-8.26-2 , , .

, ​​ . coreutils -f.

, , - Docker. , tail , script tail, , , . , .

+5

CMD json , comas. :

$ cat df.tail
FROM debian:latest
RUN touch /var/log/mylog.log
CMD ["tail", "-F", "/var/log/mylog.log"]

$ docker build -t test-tail -f df.tail .
Sending build context to Docker daemon 265.7 kB
Step 1/3 : FROM debian:latest
 ---> 7b0a06c805e8
Step 2/3 : RUN touch /var/log/mylog.log
 ---> Using cache
 ---> 412295d58dc8
Step 3/3 : CMD tail -F /var/log/mylog.log
 ---> Using cache
 ---> d7e9c7fee4a0
Successfully built d7e9c7fee4a0

$ docker run -t --rm --name test-tail test-tail
asd
^C
$

:

$ docker exec test-tail bash  -c "echo 'asd' >> /var/log/mylog.log"
+2

Source: https://habr.com/ru/post/1671543/


All Articles