Process start time for container applications is off?

Hello all,

I started using lxc for some home projects, and one of the things I did was to create a centos5.5 container. Given that this is such an ancient OS I was expecting things to not work too well, but I’m pleasantly surprised.

One thing that stumped me for a bit was the fact that the process start time reported by ps would consistently be in the future. After some digging I came to the tentative conclusion that this is due to starttime in /proc/[pid]/stat being set relative to the start time of the host, rather than the container. Since the container started some time after the host, the start time of the process therefore appears to be in the future.

I do not see this same behavior in current OS’; I looked at this in my Ubuntu 22.04 container and it shows the process start time correctly in the container - even though the starttime for the process is still relative to the host start time.

I’m therefore curious to understand how the starttime for an application in the container is adjusted so it shows correctly?


That can happen because of the uptime emulation of LXCFS.
You may be able to workaround this by doing umount /proc/uptime inside the container, though note that this will then make uptime return the host value rather than container-speciifc value.

Thanks for the response! I’ll give it a try and confirm.