<p>Since you are using a ready-made Docker image, and want additional package(s) on top of it, writing a <a href="https://docs.docker.com/engine/reference/builder/" rel="nofollow noreferrer">Dockerfile</a> would be &quot;automation&quot; of the commands. Using this you can create a new image with what you want pre-installed.</p>
<p>Example <code>Dockerfile</code>:</p>
<pre><code>FROM pimcore/pimcore:PHP7.4-apache

RUN apt-get update &amp;&amp; apt-get upgrade &amp;&amp; apt-get install -y vim
</code></pre>
<p>Then use the <code>docker build</code> command to build an image with a name (tag) that you want.</p>
<p>Example below creates image named <code>my-phpapache:7.4</code>, you can use a name that makes sense to you. This image will have <code>vim</code> installed.</p>
<pre><code>docker build -t my-phpapache:7.4 .
</code></pre>
<p>Note the <code>.</code>, this should be run in the same directory as the <code>Dockerfile</code>.</p>
<p>You may find that using the <code>Dockerfile</code> to copy configuration into the image may eliminate the need to have <code>vim</code> installed in it.</p>

CC BY-SA 4.0
2022-05-11T11:59:02.530Z
2022-05-11T11:59:02.530Z
seshadri_c
<p>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?</p>
<pre><code># apt-get update

# apt-get upgrade

# apt-get install -y vim
</code></pre>

CC BY-SA 4.0
2022-05-10T16:27:29.883Z
Which image is it? Do you build that image?
seshadri_c
CC BY-SA 4.0
2022-05-11T07:16:50.870Z
It is php: image: pimcore/pimcore:PHP7.4-apache
Taras
<docker><docker-compose>
How can I run apt-get update and apt-get upgrade commands automatically?
Taras
# How can I run apt-get update and apt-get upgrade commands automatically?

(Asked by: username_0 on 2022-05-09)

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 upgrade

# apt-get install -y vim

**Tags:** docker, docker-compose

> **Comments:**
> **username_1**: Which image is it? Do you build that image?  
> **username_0**: It is php: image: pimcore/pimcore:PHP7.4-apache  

---

## 1 answers

### Answer by username_1 on 2022-05-11. Score: 1 | Accepted answer

Since you are using a ready-made Docker image, and want additional package(s) on top of it, writing a Dockerfile would be "automation" of the commands. Using this you can create a new image with what you want pre-installed.
Example Dockerfile:
FROM pimcore/pimcore:PHP7.4-apache

RUN apt-get update && apt-get upgrade && apt-get install -y vim

Then use the docker build command 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 vim installed.
docker build -t my-phpapache:7.4 .

Note the ., this should be run in the same directory as the Dockerfile.
You may find that using the Dockerfile to copy configuration into the image may eliminate the need to have vim installed in it.


---

