Docker clock out-of-sync disallows package update and upgrade
So I wanted to install some stuff through apt-get and it crashed. It was a dependency issue. Thus, I executed
sudo apt-get update
And it crashed. Seemingly, the internal clock was out of sync.
Attemtped to use the fix propted in the readme (but for the docker image):
sudo date -s "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')"
Permission denied... After doing some research, my fix was
1. Stopping the docker container
docker stop devops199
2. Stashing a copy somewhere else
docker commit devops199 my_temporary_image
3. Making sure my local machine's clock was set properly
Because the docker image inherits the time from the machine
4. Deleting the old image
docker rm devops199
5. Re-running the image
docker run -it -d --name devops199 -e TZ=MyTimeZone my_temporary_image
Replace MyTimeZone by the appropriate one (i.e. America/New_York, Europe/Madrid ...).
The bad thing about this fix is that now I have some space occupied by my_temporary_image:
docker image list
yields
REPOSITORY TAG IMAGE ID CREATED SIZE
my_temporary_image latest 3a9438defdaf 2 hours ago 5.7GB
whitehat-machine latest 82d98c925275 2 months ago 2.65GB
As far as I know these bug look related to the fact of the architecture your are using:
windows -> wsl2 ubuntu -> docker ubuntu
Would be interesting to test the same architecture in another computer. Will set as low priority meanwhile, as your workaround works and probably most users just run windows / mac / linux distro -> docker