V
V
vladitot2019-06-03 18:25:21
PHP
vladitot, 2019-06-03 18:25:21

How to reuse layers with code in a docker container?

Hello! There is a repository with PHP code.
I would like to supply code as container to the server. That is, when pushing to the repository, I want to build a container containing the PHP code of the current version.
The sources are large, about 300 meters.
If I use the COPY instruction in the Dockerfile, then if at least one of the thousand files changes, then on the next build, the entire code will be built as a new layer, and will take another 300 megabytes.
Question! Maybe someone has come across this, and knows how to make sure that only changes to specific files are made to the container, but unchanged files are taken from the cache, as docker can do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ivankomolin, 2019-06-04
@vladitot

You are most likely confusing the concept of a container with an image.
At the time of build, it is the image that is built . From which you can then create a container
on the desired machine . Yes, if you change the files in the container, then it will grow. Therefore, when changing in the code, it is necessary to build a new image with new code, push it to the repository. And on the desired machine, pull from the repository, delete the old container and create a new one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question