How is it possible to change field "created" in docker image? - docker

I have a docker image (FIRST) with correct field "created"
Then I make a manipulation with it, correct some fields using another docker image (SECOND)
And when I use docker inspect I see that field "created" is "Created": "1980-01-01T00:00:01Z",
created 44 years ago, of course it is false
SECOND image was builded by me, it was FROM docker:latest (standarted) and I copied from local some needed files inside the container
So, how can I change field created? Why there is no timestamp anymore?
Described in problem details
SECOND dockerfile
FROM docker:latest
COPY /usr(I unpacked .deb file in local dir) /usr

Related

copy file from docker image using imageId

We have requirement in order to fasten the deployment, which is, something like this :
pull docker image
start docker container
copy 2 files from docker container to host
stop and delete docker container
execute 1st file with 2nd file as input, will check and download bigger archived files to a path (skips if bigger archived files already downloaded with integrity check passed)
start docker container with volume mapping.
This is meant to cut down the size of the docker image (say from 30GB) and fasten the deployment. However is there something alternative way , which is, can we do something :
pull docker image
depending on imageId, we can find the detail of files under /var/lib/docker
copy 2 files from /var/lib/docker path to another specific path
question mark - is above step possible in order to get the files according to imageid (suppose two or more docker images were there).

Undo Dockerfile VOLUME directive from a base image [duplicate]

This question already has answers here:
Docker base image includes a volume. How can I stop mounting it in my derived image
(2 answers)
Closed 2 years ago.
I have an image derived from the Postgres official image, whose Dockerfile includes the following:
VOLUME /var/lib/postgresql/data
I'd like to create my own image based on this official image, but I don't want it to reference any volume. I'd like the Postgres data to be inside my image.
Any ideas please?
You can't undo the VOLUME directive.
See this open issue on github: Reset properties inherited from parent image #3465
There are some solutions, based on answers of theses questions:
"Remove" a VOLUME in a Dockerfile
How to remove a volume in a Dockerfile
How to remove configure volumes in docker images
You can copy the base image and remove the VOLUME manually.
A workaround, see docker-copyedit. The script will docker save and image into an archive to modify its metadata and docker load it back into an image.
If you don't care about the volume and just want to put the data in the image, you'll have to use another location for the data and you can use use the environment variable PGDATA to define the new location.

How can I find the images being pulled from the SHA1s?

When we run a docker container if the relevant image is not in the local repo it is being downloaded but in a specific sequence i.e parent images etc.
If I don’t know anything about the image how could I find from which images is being based on based on the layers pulled as displayed in a docker run?
The output only shows the SHA1s on any docker run etc
AFAIK, you can't, there is no reverse function for a hash.
Docker just tries to get the image from local, when its not available tries to fetch it from the registry. The default registry is DockerHub.
When you don't specify any tag when running the container ie: docker run ubuntu instead of docker run ubuntu:16.04 the default latest is used. You'll have to visit the registry and search which version the latest tag is pointing to.
Usually in DockerHub there is a link pointing the GitHub repo where you can find the Dockerfile, in the Dockerfile you can find how its built, including the root image.
You also can get some extra info with docker image inspect image:tag, but you'll find more hashes in the layers.
Take a look to dockerfile-from-image
"Similar to how the docker history command works, the dockerfile-from-image script is able to re-create the Dockerfile (approximately) that was used to generate an image using the metadata that Docker stores alongside each image layer."
With this, maybe you can get the source of the image.

Docker making image with Dockerfile and permanent helper files in its volume

New to Docker.
Is there a possible way to create docker image with some helper files which will be permanent in the volume of the image under container certain folder, without dependency to copy them each build time from the host machine where we build the image, since I may have host which down't contain these files.
Any help will be greatly appreciated
Yes, you can create first base image where these files will be placed. And you need to push this image to repository. After it you can create other images based on first image.
I try to explain idea in example.
Base image has Dockerfile
FROM ubuntu:16.04
...
COPY /my_big_files /my_big_files/
Build this image with tag my_image_with_files:latest and push it to repository
Other images based on first image can be buit on the another PC.
Dockerfile
FROM my_image_with_files:latest
...
RUN ls /by_big_files/ # <- your files already there!

How does Docker name repositories?

In a directory called ringer i've created a simple Dockerfile that will install some stuff and mount my app... I have never explicitly set a name.
I then used a docker-compose.yml file to define web and pointed it at the Dockerfile i mentioned above.
When i run docker images i see the following:
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ringer_web latest bf9b931e1030 8 minutes ago 938.9 MB
It looks like Docker named my image's repository after the local directory and image name... My question is, how exactly does Docker choose to name an image's repository? (and if applicable, why)
From the docs:
COMPOSE_PROJECT_NAME
Sets the project name, which is prepended to the name of every container started by Compose. Defaults to the basename of the current working directory.
BTW, this is not docker, but docker-compose that is deciding on the name. To change it, set the COMPOSE_PROJECT_NAME before running docker-compose:
COMPOSE_PROJECT_NAME=myprefix docker-compose up

Resources