Dockerfile use FROM gitlab server

Hello,

I’ve a privat gitlab where I can clone and so on via ssh from my linux machine. Now I have a GitLab repository which contains a Dockerfile. This file works without problems, when I clone it localy and start docker build.

The Dockerfile and all used installation files are saved in a subdirectory.

git@GitLab-Server:GoupA/SubGroupB/ProjectDocker.git/ConfigDir

Now my big question. What mus I write in the first line from my new Dockerfile to use this a parent image?

FROM ubuntu:2204

I have try some syntax, but I have not found the correct syntax:

FROM git@gitlab.mycom:groupA/subgroupB/project/dir:latest

Have everyone a good information for me? I will not push it into a other reporsitory.

Best regards,
Bernd

The very same image name you use, when you push the created image into the container registry.

mmh, I think I have not write correct what I will do.

I have a Dockerfile what works and is saved into a GitLab server.
Now I will write a new Dockerfile which use the saved Dockerfile from GitLab server as parent.
During start of the build of the new image is the parent image not build.

I agree, we are not on the same page yet:

  1. You have a Dockerfile for a base image, create the base image, then push the image as fqdn.of.repository.in.gitlab/path/to/repo:tag to the registry
  2. If you want another Dockerfile to use the previously created and pushed image as base image, you use FROM fqdn.of.repository.in.gitlab/path/to/repo:tag

It seems you assume that a Dockerfile can inherit or extend an existing Dockerfile. Instead, it works like written above.

I hope now I have understand it correct.

The parent docker Dockfile must build and push the image to the GitLag server befor I can use it in other Dockerfiles? My image have more than 4GB at this point and the build directory itself only have 800MB.

I would have thought that the first image would be created automatically and not that the image itself would have to be saved in GitLab.

Now I think it is easier to write one Dockerfile which contain booth Dockerfile. It is not so big at the moment.

We are on the same page now :slight_smile:

Make sure to follow the Dockerfile best practices to optimize the target image size: