How can I run apt-get update and apt-get upgrade commands automatically?
I have a docker container where I run a few commands as a root user each time it is created from an image. Is it possible to automate running these commands as a root administrator user each time my container is created?
# apt-get update
apt-get install -y vim
Since you are using a ready-made Docker image, and want additional package(s) on top of it, writing a https://docs.docker.com/engine/reference/builder/ would be "automation" of the commands. Using this you can create a new image with what you want pre-installed.
RUN apt-get update && apt-get upgrade && apt-get install -y vim
Then use the
docker buildcommand to build an image with a name (tag) that you want.
Example below creates image named
my-phpapache:7.4, you can use a name that makes sense to you. This image will have
docker build -t my-phpapache:7.4 .
., this should be run in the same directory as the
You may find that using the
Dockerfileto copy configuration into the image may eliminate the need to have
viminstalled in it.