skip to Main Content

I am relatively new to Docker and have noticed a strange issue with the images I am creating.

My very simple Dockerfile looks like this:

FROM php:5.4-apache
COPY --chown=www-data:www-data src /var/www/html
COPY php/php.ini /usr/local/etc/php
RUN docker-php-ext-install pdo pdo_mysql

After I build the image and use the ‘docker image ls’ command I get the following output.

REPOSITORY              TAG       IMAGE ID       CREATED        SIZE
xxxxx/dcalc             latest    ea718faxxxxx   6 years ago    477MB

I don’t understand why the CREATED date is showing 6 years ago. I get that the base image (referred to in the FROM command) is that old, but shouldn’t my image which has a COPY command in it create a new image with a current created date?

If this is expected behaviour can somebody explain why it is correct?

EDIT: I am on MacOS using Docker Desktop, but its the same behaviour on Linux (Docker version 20.10.17, build 100c701).

Thanks.

2

Answers


  1. If you want to check the date of docker image which is created on your system, you can use:-

    docker ps -a
    

    docker images command shows the date which the image is created.

    Login or Signup to reply.
  2. The best way to get rid of this file modified date issue is to set timezone for linux instance

    in Dockerfile

    RUN rm /etc/localtime
    RUN ln -s /usr/share/zoneinfo/Europe/Istanbul /etc/localtime
    

    Change your timezone and find it from /usr/share/zoneinfo/* for your timezone.

    docker-compose down
    docker-compose build
    docker-compose up -d
    

    timezone of you and docker instance is now the same.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search