<p>This is my DockerFile</p>
<pre><code># set base image (host OS)
FROM python:3.8

# set the working directory in the container
WORKDIR /code

# command to run on container start
RUN mkdir -p /tmp/xyz-agent
</code></pre>
<p>And when I execute the following command -
<code>docker -v build .</code> the docker builds successfully and I don't get any error. This is the output -</p>
<pre><code>Step 1/3 : FROM python:3.8
3.8: Pulling from library/python
b9a857cbf04d: Already exists 
d557ee20540b: Already exists 
3b9ca4f00c2e: Already exists 
667fd949ed93: Already exists 
4ad46e8a18e5: Already exists 
381aea9d4031: Pull complete 
8a9e78e1993b: Pull complete 
9eff4cbaa677: Pull complete 
1addfed3cc19: Pull complete 
Digest: sha256:fe08f4b7948acd9dae63f6de0871f79afa017dfad32d148770ff3a05d3c64363
Status: Downloaded newer image for python:3.8
 ---&gt; b0358f6298cd
Step 2/3 : WORKDIR /code
 ---&gt; Running in 486aaa8f33ad
Removing intermediate container 486aaa8f33ad
 ---&gt; b798192954bd
Step 3/3 : CMD ls
 ---&gt; Running in 831ef6e6996b
Removing intermediate container 831ef6e6996b
 ---&gt; 36298963bfa5
Successfully built 36298963bfa5
</code></pre>
<p>But when I login inside the container using terminal. I don't see the directory created.
Same goes for other commands as well. Doesn't throw error, doesn't create anything.
NOTE: I'm using Docker for Desktop with Kubernetes running.</p>

bosari
<p>Are you sure you create your container from the newly built image ?</p>
<p>Let's take a look again at the whole process:</p>
<p>We have the following <code>Dockerfile</code>:</p>
<pre><code># set base image (host OS)
FROM python:3.8

# set the working directory in the container
WORKDIR /code

# command to run on container start
RUN mkdir -p /tmp/xyz-agent
</code></pre>
<p>In the directory where <code>Dockerfile</code> is placed, we run:</p>
<pre><code>docker build .
</code></pre>
<p>Then we run:</p>
<pre><code>docker images
</code></pre>
<p>which shows us our newly built image:</p>
<pre><code>$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
&lt;none&gt;       &lt;none&gt;    775e0c698e81   29 seconds ago   882MB
python       3.8       b0358f6298cd   6 days ago       882MB
</code></pre>
<p>Now we need to tag our newly created image:</p>
<pre><code>docker tag 775e0c698e81 my-python:v1
</code></pre>
<p>When we run <code>docker images</code> again it shows us:</p>
<pre><code>$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED              SIZE
my-python    v1        775e0c698e81   About a minute ago   882MB
python       3.8       b0358f6298cd   6 days ago           882MB
</code></pre>
<p>Let's run a new container from this image and check whether our directory has been successfully created:</p>
<pre><code>$ docker run -ti my-python:v1 /bin/bash
root@6e93ed4a6e94:/code# pwd
/code
root@6e93ed4a6e94:/code# ls -ld /tmp/xyz-agent
drwxr-xr-x 2 root root 4096 Jan 19 14:58 /tmp/xyz-agent
root@6e93ed4a6e94:/code#
</code></pre>
<p>As you can see above, <code>/tmp/xyz-agent</code> directory is in it's place as expected. I hope this helps you figure out where you are making a mistake.</p>
