<p>I have a container that I need to configure for k8s yaml. The workflow on <code>docker run</code> using the terminal looks like this.:</p>
<pre><code>docker run -v $(pwd):/projects \
             -w /projects \
             gcr.io/base-project/myoh:v1 init *myproject*
</code></pre>
<p>This command creates a directory called <em>myproject</em>. To complete the workflow, I need to cd into this <em>myproject</em> folder and run:</p>
<pre><code>docker run -v $(pwd):/project \
             -w /project \
             -p 8081:8081 \
             gcr.io/base-project/myoh:v1
</code></pre>
<p>Any idea how to convert this to either a docker-compose or a k8s pods/deployment yaml? I have tried all that come to mind with no success.</p>

Paschal
<p>The bind mount of the current directory can't be translated to Kubernetes at all.  There's no way to connect a pod's filesystem back to your local workstation.  A standard Kubernetes setup has a multi-node installation, and if it's possible to directly connect to a node (it may not be) you can't predict which node a pod will run on, and copying code to every node is cumbersome and hard to maintain.  If you're using a hosted Kubernetes installation like GKE, it's even possible that the cluster autoscaler will create and delete nodes automatically, and you won't have an opportunity to manually copy things in.</p>
<p>You need to build your application code into a custom image.  That can set the desired <code>WORKDIR</code>, <code>COPY</code> the code in, and <code>RUN</code> any setup commands that are required.  Then you need to push that to an image repository, like GCR</p>
<pre><code>docker build -t gcr.io/base-project/my-project:v1 .
docker push gcr.io/base-project/my-project:v1
</code></pre>
<p>Once you have that, you can create a minimal Kubernetes <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">Deployment</a> to run it.  Set the GCR name of the image you built and pushed as its <code>image:</code>.  You will also need a <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Service</a> to make it accessible, even from other Pods in the same cluster.</p>
