I'm a beginner with Docker and I'm trying to get to grips with its structures and processes. I have the following scenario at work that I'm trying to figure out.
I have a docker container my-container
running on a node. Inside this container is a Dockerfile, which I've updated with a couple of RUN lines so that it will install something every time the container is run. I removed the existing docker image, and I want to rebuild and tag a docker image using the updated Dockerfile. The Dockerfile edit and image rebuild is only required once.
Is there a best, or generally accepted method of getting docker build
to run using a Dockerfile that is located within a container? I've searched around and could find a few different methods:
docker build
from within the container, using Docker in Docker as outlined heredocker build
from within the container by passing the socket (although this should never be done, is there a way of closing the vulnerability after you've run the command (a once off) and running the container again without the bind mounting using -v?docker build
from outside the container, but using the url of the container that contains the updated dockerfile as the build context? See:
3 different ways to provide docker build context and Docker docs.Thanks
you can define the Dockerfile inside the container as volume and then call that Dockerfile from outside(host) with docker build command. i think its the easiest way.