<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>For creating a directory inside a container it is better to use the <code>RUN</code> command and specify <code>-p</code> parameter for <code>mkdir</code> to create the parent directories.</p>
<p>You can also try to build your container via docker-compose.yml which contains</p>
<pre class="lang-yaml prettyprint-override"><code>version: '3'
services:
  python-app:
    build: .
    container_name: &lt;your_python_container_name&gt;
    working_dir: /code
    volumes:
      - &lt;path_on_host_for_share&gt;:/code
    stdin_open: true
    tty: true
</code></pre>
<p>and build your container with <code>docker-compose build</code> and <code>docker-compose up</code> afterwards.</p>
