Docker Community Forums

Share and learn in the Docker community.

How can I reuse the image/container?


(Zhshqzyc) #1

In my Dockerfile, I have the code
ADD . /app

It works well for the first deployment. However the second time when I made a little change of my application code then push it to the Linux server with the same Dockerfile.

I find that a new container was created. If I repeate N times, therefore N containers will be created.
Is it a best practice? I think at least it wastes space and people may be confusing which one is the latest application.

So how to avoid it? Not using ADD?

(Jeff Anderson) #2

You’ll definitely want to continue using ADD. Your docker image becomes your deploy artifact.

When you have a new version of the image and create a new container, you can clean up the old containers and images since they are no longer needed.