<p>I need to connect to windows remote server(shared drive) from GO API hosted in the alpine linux. I tried using tcp,ssh and ftp none of them didn't work. Any suggestions or ideas to tackle this?</p>

Srikanth Reddy
<p>Before proceeding with debugging the GO code, it would be needed to do some "unskilled labour" within container in order to ensure pre-requisites are met: </p>

<ol>
<li>samba client is installed and daemons are running; </li>
<li>the target name gets resolved; </li>
<li>there are no connectivity issues (routing, firewall rules, etc); </li>
<li>there are share access permissions; </li>
<li>mounting remote volume is allowed for the container.</li>
</ol>

<p>Connect to the container: </p>

<pre><code>$ docker ps 
$ docker exec -it container_id /bin/bash
</code></pre>

<p>Samba daemons are running: </p>

<pre><code>$ smbd status
$ nmbd status
</code></pre>

<p>You use the right name format in your code and command lines: </p>

<pre><code>UNC notation =&gt;  \\server_name\share_name
URL notation =&gt;  smb://server_name/share_name
</code></pre>

<p>Target name is resolvable</p>

<pre><code>$ nslookup server_name.domain_name
$ nmblookup netbios_name 
$ ping server_name
</code></pre>

<p>Samba shares are visible</p>

<pre><code>$ smbclient -L //server [-U user]       # list of shares
</code></pre>

<p>and accessible (<code>ls</code>, <code>get</code>, <code>put</code> commands provide expected output here)</p>

<pre><code>$ smbclient //server/share
&gt; ls 
</code></pre>

<p>Try to mount remote share as suggested by <a href="https://stackoverflow.com/users/7053644/cwadley">@cwadley</a> (mount could be prohibited by default in Docker container): </p>

<pre><code>$ sudo mount -t cifs -o username=geeko,password=pass //server/share /mnt/smbshare
</code></pre>

<p>For investigation purposes you might use the Samba docker container available at <a href="https://github.com/dperson/samba" rel="nofollow noreferrer">GitHub</a>, or even deploy your application in it since it contains Samba client and helpful command line tools: </p>

<pre><code>$ sudo docker run -it -p 139:139 -p 445:445 -d dperson/samba
</code></pre>

<p>After you get this working at the Docker level, you could easily reproduce this in Kubernetes. </p>

<p>You might do the checks from within the running Pod in Kubernetes: </p>

<pre><code>$ kubectl get deployments --show-labels
$ LABEL=label_value; kubectl get pods -l app=$LABEL -o custom-columns=POD:metadata.name,CONTAINER:spec.containers[*].name
$ kubectl exec pod_name -c container_name -- ping -c1 server_name
</code></pre>

<p>Having got it working in command line in Docker and Kubernetes, you should get your program code working also. </p>

<p>Also, there is a really thoughtful discussion on StackOverflow regards Samba topic:<br>
<a href="https://stackoverflow.com/questions/27989751/mount-smb-cifs-share-within-a-docker-container">Mount SMB/CIFS share within a Docker container</a></p>
