Change system date time in Docker containers without impacting host - linux

Is it possible to change the system time in Docker containers without changing the host itself?
We are using Docker containers for testing which are sometimes time sensitive. I notice that any changes made to the host time are reflected to the Docker containers right away (which makes sense since they are using the same kernel). I am hoping, however, that Docker provides a way for you to somehow override the start time of the container and move from thereon.

Just a follow up for those looking to have different datetime in Docker containers, https://github.com/wolfcw/libfaketime should probably be able to do the job.

Simple:
Steps:
First check the localtime of the docker container:
[root#locdb oracle]# zdump /etc/localtime
/etc/localtime Tue May 22 13:59:40 2018 UTC
Check the timezones like below:
[root#locdb oracle]# zdump /usr/share/zoneinfo/* | tail -10
/usr/share/zoneinfo/UTC Tue May 22 14:01:21 2018 UTC
/usr/share/zoneinfo/Universal Tue May 22 14:01:21 2018 UTC
/usr/share/zoneinfo/W-SU Tue May 22 17:01:21 2018 MSK
/usr/share/zoneinfo/WET Tue May 22 15:01:21 2018 WEST
/usr/share/zoneinfo/Zulu Tue May 22 14:01:21 2018 UTC
/usr/share/zoneinfo/iso3166.tab Tue May 22 14:01:21 2018
/usr/share/zoneinfo/posix Tue May 22 14:01:21 2018
/usr/share/zoneinfo/posixrules Tue May 22 10:01:21 2018 EDT
/usr/share/zoneinfo/right Tue May 22 14:01:21 2018
/usr/share/zoneinfo/zone.tab Tue May 22 14:01:21 2018
Copy the one that you need for example :
cp /usr/share/zoneinfo/UTC /etc/localtime

As described in detail here the solution that I follow is to run docker on top of a VM and automate the whole process of changing-vm-time, running-vm and running-container, via vagrant.

Related

clamav-daemon doesn't create /var/run/clamd.ctl [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 days ago.
Improve this question
I installed clamav-daemon on Debian 11 and when I try to start it, it doesn't create the LocalSocket /var/run/clamd.ctl.
LocalSocket in my /etc/clamav/clamd.conf:
LocalSocket /var/run/clamav/clamd.ctl
systemctl status clamav-daemon.service brings:
● clamav-daemon.service - Clam AntiVirus userspace daemon
Loaded: loaded (/lib/systemd/system/clamav-daemon.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/clamav-daemon.service.d
└─extend.conf, override.conf
Active: active (running) since Fri 2023-02-17 15:55:18 CET; 34min ago
Docs: man:clamd(8)
man:clamd.conf(5)
https://docs.clamav.net/
Process: 37394 ExecStartPre=/bin/mkdir -p /run/clamav (code=exited, status=0/SUCCESS)
Process: 37395 ExecStartPre=/bin/chown clamav /run/clamav (code=exited, status=0/SUCCESS) Main PID: 37396 (clamd)
Tasks: 1 (limit: 1129)
Memory: 489.8M
CPU: 52.996s
CGroup: /system.slice/clamav-daemon.service
└─37396 /usr/sbin/clamd --foreground=true
Feb 17 15:55:18 cc700x-irmler systemd[1]: clamav-daemon.service:
Consumed 11.193s CPU time. Feb 17 15:55:18 cc700x-irmler systemd[1]:
Starting Clam AntiVirus userspace daemon... Feb 17 15:55:18
cc700x-irmler systemd[1]: Started Clam AntiVirus userspace daemon.
So, it seems everything to be fine. But:
systemctl status clamav-daemon.socket brings:
Unit clamav-daemon.socket could not be found.
/var/log/clamav/clamav.log brings (when starting):
Fri Feb 17 15:55:19 2023 -> +++ Started at Fri Feb 17 15:55:19 2023
Fri Feb 17 15:55:19 2023 -> Received 0 file descriptor(s) from
systemd. Fri Feb 17 15:55:19 2023 -> clamd daemon 0.103.7 (OS:
linux-gnu, ARCH: x86_64, CPU: x86_64) Fri Feb 17 15:55:19 2023 -> Log
file size limited to 4294967295 bytes. Fri Feb 17 15:55:19 2023 ->
Reading databases from /var/lib/clamav Fri Feb 17 15:55:19 2023 -> Not
loading PUA signatures. Fri Feb 17 15:55:19 2023 -> Bytecode: Security
mode set to "TrustSigned". Fri Feb 17 16:08:12 2023 -> Loaded 8652992
signatures.
/var/log/clamav/clamav-milter.log brings (as the /var/run/clamav/clamd.ctl is missing):
Fri Feb 17 16:27:05 2023 -> WARNING: No clamd server appears to be
available Fri Feb 17 16:28:05 2023 -> WARNING: No clamd server appears
to be available Fri Feb 17 16:29:04 2023 -> WARNING: No clamd server
appears to be available Fri Feb 17 16:30:03 2023 -> WARNING: No clamd
server appears to be available Fri Feb 17 16:31:02 2023 -> WARNING: No
clamd server appears to be available Fri Feb 17 16:32:01 2023 ->
WARNING: No clamd server appears to be available
The permissions for /var/run/ is set for the user "clamav" and group "root". clamav is also the user who runs the process:
ps aux | grep clamav
clamav 500 0.0 0.0 58248 704 ? Ss 14:22 0:00
/usr/bin/freshclam -d --foreground=true clamav 31064 0.0 0.0
349480 52 ? Ssl 14:55 0:00 /usr/sbin/clamav-milter
--config-file=/etc/clama v/clamav-milter.conf clamav 37396 2.2 42.5 1395520 425952 ? Ds 15:55 0:55 /usr/sbin/clamd --foreground=true root 38870 0.0 0.0 6244 700 pts/1 S+ 16:36 0:00 grep clamav
I tried already to purge/install and also --reinstall clamav and clamav-daemon and I also tried a dpkg-reconfigure on clamav-daemon. And I also tried a clean reboot. Nothing changed the situation.
I have no idea what else I could try. Has anyone an idea?
Thanks a lot!

Silence sysstat-collect.service?

The sar tool collects load values every 10 minutes on my CentOS Linux release 8.5.2111
via the service sysstat-collect.service. It fills /var/log/messages with:
Dec 26 12:50:04 node systemd[1]: Starting system activity accounting tool...
Dec 26 12:50:04 node systemd[1]: sysstat-collect.service: Succeeded.
Dec 26 12:50:04 node systemd[1]: Started system activity accounting tool
Every 10 minutes. That's annoying, I want to silence it. Is it possible??
Thanks in advance
You can use logrotate to select what logs you want to keep or delete

Node.js Date does not consider DST (daylight saving time)

I'm living in Vancouver, west coast of North America, Canada. The original timezone here is PST (pacific standard time, UTC - 8h), but it's now PDT (pacific daylight time, UTC - 7h) since the daylight saving time has started.
The problem is that Node.js uses the original non-DST time, while Ubuntu returns DST.
In the following, both should be 21:44.
$ echo `date` , `node -e "console.log(new Date().toString())"`
Mon May 25 21:44:57 DST 2020 , Mon May 25 2020 20:44:57 GMT-0800 (GMT-08:00)
Why does this happen? How to let Node.js recognize DST?
I use Noce.js v12.16.3 on Ubuntu 18.04.4 as WSL on Windows 10. (Node.js v12.16.3 for Windows works correctly.) TZ env is not set.
UPDATE I don't want to install external libraries.
A more accurate library would be moment.js. You can set the time to recognize DST like this:
moment(timestamp).tz(timezone).isDST()
Here is an example:
moment(1451624400000).tz('America/New_York').isDST();
You can read more about recognized timestamps and timezones in the documentation on the website that I linked above.
My test shows that node does honor daylight saving time:
$ date; node -e "console.log(new Date().toString())";
Fri Jul 17 23:13:32 EDT 2020
Fri Jul 17 2020 23:13:32 GMT-0400 (Eastern Daylight Time)
$ date --date='Fri Jul 17 2020 23:13:32 GMT-0400'
Fri Jul 17 23:13:32 EDT 2020
$ node -v
v10.21.0
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal

Servers with same timezone but different time

I have 3 servers, 2 on AWS and one on Digital Ocean, and the timezone for all is set to CDT. But when I check the current time on all 3 by using the date command via command line, none of them matches.
Server1: Wed Jun 12 23:36:01 CDT 2019
Server2: Wed Jun 12 23:45:51 CDT 2019
Server3: Wed Jun 12 23:38:39 CDT 2019
Could anyone please suggest what needs to be done here? Thanks.
Since you have not explicitly said that you have ntp running on them, you'll need to install that. Once that is installed and set up properly, you should show the same exact time on all of them.

Long MAC addres in Cisco DHCP binding

i have problem whith Cisco DHCP. On switch C6506 in "sh ip dhcp binding" table are the long MAC addres. What is the problem? The one MAC (00.16e6.448a.e4) have more IP addres.
158.195.40.46 id ffe6.448a.e400.0100.011d.69e6.3900.16e6.448a.e4 Mar 12 2016 03:35 PM
158.195.46.201 id ffe6.448a.e400.0100.011d.d88f.c400.16e6.448a.e4 Mar 12 2016 12:10 PM
158.195.46.202 id 0100.16e6.448a.e4 Mar 12 2016 02:09 PM
158.195.46.203 id ffe6.448a.e400.0100.011d.d8b0.1b00.16e6.448a.e4 Mar 12 2016 02:28 PM
158.195.46.204 id ffe6.448a.e400.0100.011d.d8b2.0500.16e6.448a.e4 Mar 14 2016 09:53 PM
Answer is here: https://supportforums.cisco.com/discussion/12708241/weird-mac-address-dhcp-binding
"Okay. Please check the file /etc/dhcp/dhclient.conf on the Fedora machine and add the following line to the file:
send dhcp-client-identifier = hardware;
If there are any other instances of this command in that file, please remove them - make sure this is the only one."

Resources