projectatomic / oci-systemd-hook

OCI hook to enable running systemd in a container
GNU General Public License v3.0
63 stars 26 forks source link

can not get the container's journal information on the host, using journalctl. #106

Open 0x0916 opened 5 years ago

0x0916 commented 5 years ago

I created a container image based on a Dockerfile like the following:

cat Dockerfile
FROM fedora:latest
ENV container docker
RUN yum -y update && yum -y install httpd && yum clean all
RUN systemctl mask dnf-makecache.timer && systemctl enable httpd
CMD [ "/sbin/init" ]

Then execute the following commands

# systemctl status systemd-machined.service 
● systemd-machined.service - Virtual Machine and Container Registration Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-machined.service; static; vendor preset: disabled)
   Active: active (running) since Mon 2018-10-29 11:15:25 +08; 28s ago
     Docs: man:systemd-machined.service(8)
           http://www.freedesktop.org/wiki/Software/systemd/machined
 Main PID: 2577 (systemd-machine)
   Status: "Processing requests..."
    Tasks: 1
   Memory: 424.0K
   CGroup: /system.slice/systemd-machined.service
           └─2577 /usr/lib/systemd/systemd-machined

Oct 29 11:15:25 localhost.localdomain systemd[1]: Starting Virtual Machine and Container Registration Service...
Oct 29 11:15:25 localhost.localdomain systemd[1]: Started Virtual Machine and Container Registration Service.
Oct 29 11:15:25 localhost.localdomain systemd-machined[2577]: New machine 6c4741198c33df0e25ecbff31fa9634f.
# cat /etc/oci-register-machine.conf 
# Disable oci-register-machine by setting the disabled field to true
disabled : false
# docker build -t httpd .
# docker run -tid --stop-signal=RTMIN+3 httpd

But I can not get the container's journal information on the host, using journalctl.

# machinectl list
MACHINE                          CLASS     SERVICE
6c4741198c33df0e25ecbff31fa9634f container docker 

1 machines listed.
# journalctl -M 6c4741198c33df0e25ecbff31fa9634f
No journal files were found.
-- No entries --

Any ideas are welcome.


my docker version is:

# docker version
Client:
 Version:         1.13.1
 API version:     1.26
 Package version: docker-1.13.1-75.git8633870.el7.centos.x86_64
 Go version:      go1.9.4
 Git commit:      8633870/1.13.1
 Built:           Fri Sep 28 19:45:08 2018
 OS/Arch:         linux/amd64

Server:
 Version:         1.13.1
 API version:     1.26 (minimum version 1.12)
 Package version: docker-1.13.1-75.git8633870.el7.centos.x86_64
 Go version:      go1.9.4
 Git commit:      8633870/1.13.1
 Built:           Fri Sep 28 19:45:08 2018
 OS/Arch:         linux/amd64
 Experimental:    false
rhatdan commented 5 years ago

You need oci-register-machine to make that work. But that has caused lots of issues with systemd doing some weird things to the containers, so we have decided to stop supporting oci-register-machine, for now.

You need to exec into the container to view the logs.

0x0916 commented 5 years ago

@rhatdan thank you for your info.

I have already installed oci-register-machine-0-6.git2b44233.el7.x86_64. but journalctl -M xxx still can not get the logs for containers.

Currently, it is better to exec into container to check the logs for us.