Python: datetime.datetime.now() always returns Container start time

Created on 26 Apr 2019  路  4Comments  路  Source: docker-library/python

Hello,

im trying to figgure out why this happens, but when i have a datetime.datetime.now() inside my Python Code it will always return the start time of the Container no matter if i start the script with container start or manually inside the Container.

I dont know if this is normal or intended, but i hope i just misusing something.
This is my actual Dockerfile:

FROM python:3.7.3-stretch
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install git -y
RUN pip install -r requirements.txt
RUN apt-get update
RUN apt-get install locales -y
RUN apt-get install nano -y
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
RUN echo "Europe/Berlin" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata
ENV TZ=Europe/Brussels
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
COPY . /code

Maybe someone could help me with this.

Most helpful comment

Yeah my issue was also dumb,

Turned out I did this:

def bad(start=datetime.datettime.now()):
    print(start)

How can I expect start to be different? 馃

Thanks for help.

All 4 comments

Okay im definitely just stupid =/
It was a mistake on my Site so this Issue isn't an issue its just my dumbness =D

@NoirPi can you please say what was the issue? I am hitting the same 馃

@NoirPi can you please say what was the issue? I am hitting the same 馃

How you implement the "datetime.datetime.now" inside your code?
In my case i've tried to put inside a dict which obviously wouldnt work.

Yeah my issue was also dumb,

Turned out I did this:

def bad(start=datetime.datettime.now()):
    print(start)

How can I expect start to be different? 馃

Thanks for help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sevdog picture sevdog  路  4Comments

ethanabrooks picture ethanabrooks  路  4Comments

zybjcdl picture zybjcdl  路  4Comments

ElianoMarques picture ElianoMarques  路  5Comments

caulagi picture caulagi  路  5Comments