title: Unable to build docker container: Can't add file <file> to tar: io: read/write on closed pipe
body: <p>I'm trying to build a container on a raspberry pi from a mac over ssh. I'm setting <code>DOCKER_HOST</code> to <code>ssh://root@192.168.1.11</code> (192.168.1.11 is the IP of my raspberry pi).</p>
  <p>The docker build command is failing with the following error message:</p>
  <pre><code>ERRO[0000] Can't add file /Users/brian/git/github/proj/backend/apps/accounts/managers.py to tar: io: read/write on closed pipe 
  ERRO[0000] Can't close tar writer: io: read/write on closed pipe 
  error during connect: Post &quot;http://docker/v1.24/build?buildargs=%7B%7D&amp;cachefrom=%5B%5D&amp;cgroupparent=&amp;cpuperiod=0&amp;cpuquota=0&amp;cpusetcpus=&amp;cpusetmems=&amp;cpushares=0&amp;dockerfile=Dockerfile&amp;labels=%7B%7D&amp;memory=0&amp;memswap=0&amp;networkmode=default&amp;rm=1&amp;shmsize=0&amp;t=localhost%3A5000%2Fbackend%3Ae150d93&amp;target=&amp;ulimits=null&amp;version=1&quot;: write |1: broken pipe
  </code></pre>
  <p>The docker version on my mac is:</p>
  <pre><code>docker --version
  Docker version 20.10.7, build f0df350
  </code></pre>
  <p>The docker version on my raspberry pi is:</p>
  <pre><code>docker --version
  Docker version 20.10.7, build 20.10.7-0ubuntu1~20.04.1
  </code></pre>
  <p>The container I'm trying to build uses this Dockerfile:</p>
  <pre><code>FROM --platform=linux/amd64 python:3.9
  ENV PYTHONUNBUFFERED 1
  ENV PYTHONDONTWRITEBYTECODE 1
  RUN mkdir /code
  WORKDIR /code
  ADD requirements.txt /code/
  RUN pip3 install -r requirements.txt
  ADD . /code/
  RUN useradd -m app
  USER app
  </code></pre>
  <p>I am able to build an image with this Docker file on my mac and also on my raspberry pi.</p>
  <p>I have found a few other issues on SO/GitHub that may be related:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/45928223/docker-cant-add-file-path-to-tar-readlink-path-the-system-cannot-find-the">Docker &quot;Can&#39;t add file &lt;path&gt; to tar: readlink &lt;path&gt; The system cannot find the file specified&quot;</a></li>
  </ul>
  <p>Here's some more information from the raspberry pi:</p>
  <pre><code>ubuntu@ubuntu:~$ df -h
  Filesystem      Size  Used Avail Use% Mounted on
  udev            3.8G     0  3.8G   0% /dev
  tmpfs           782M  2.8M  779M   1% /run
  /dev/mmcblk0p2   29G   14G   15G  49% /
  tmpfs           3.9G     0  3.9G   0% /dev/shm
  tmpfs           5.0M     0  5.0M   0% /run/lock
  tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
  /dev/mmcblk0p1  253M  120M  133M  48% /boot/firmware
  tmpfs           782M     0  782M   0% /run/user/1000
  </code></pre>
  <p>On the raspberry pi I'm having trouble finding logs from the failed build command. If I restart docker on the raspberry pi:</p>
  <pre><code>sudo systemctl restart docker
  </code></pre>
  <p>and then get the logs:</p>
  <pre><code>sudo journalctl -fu docker.service
  </code></pre>
  <p>and then run the docker build command again, I don't see any new logs when I run <code>sudo journalctl -fu docker.service</code> again.</p>
  <p>Is there another way I can debug the failed docker build command?</p>
  <p>Here is <code>docker info</code> from my raspberry pi:</p>
  <pre><code>ubuntu@ubuntu:~$ docker info
  Client:
   Context:    default
   Debug Mode: false
  
  Server:
   Containers: 21
    Running: 1
    Paused: 0
    Stopped: 20
   Images: 95
   Server Version: 20.10.7
   Storage Driver: overlay2
    Backing Filesystem: extfs
    Supports d_type: true
    Native Overlay Diff: true
    userxattr: false
   Logging Driver: json-file
   Cgroup Driver: cgroupfs
   Cgroup Version: 1
   Plugins:
    Volume: local
    Network: bridge host ipvlan macvlan null overlay
    Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
   Swarm: inactive
   Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
   Default Runtime: runc
   Init Binary: docker-init
   containerd version: 
   runc version: 
   init version: 
   Security Options:
    apparmor
    seccomp
     Profile: default
   Kernel Version: 5.4.0-1029-raspi
   Operating System: Ubuntu 20.04.2 LTS
   OSType: linux
   Architecture: aarch64
   CPUs: 4
   Total Memory: 7.628GiB
   Name: ubuntu
   ID: 24DG:6BVV:K3TX:HT64:4U2M:DFHX:2RQA:ENP5:J2WC:V3VS:UKV3:M3TL
   Docker Root Dir: /var/lib/docker
   Debug Mode: false
   Username: briancaffey
   Registry: https://index.docker.io/v1/
   Labels:
   Experimental: false
   Insecure Registries:
    127.0.0.0/8
   Live Restore Enabled: false
  
  WARNING: No memory limit support
  WARNING: No swap limit support
  WARNING: No kernel memory TCP limit support
  WARNING: No oom kill disable support
  </code></pre>
  <p><strong>Update 8/8/2021</strong>: I didn't have certificate-based SSH access setup between my raspberry pi and Mac. Adding <code>-l &quot;debug&quot;</code> to my <code>docker build</code> command this was more clear:</p>
  <pre><code>DEBU[0000] commandconn: starting ssh with [-l ubuntu -- 192.168.1.11 docker system dial-stdio] 
   EBU[0000] commandconn (ssh):Permission denied, please try again.
   EBU[0000] commandconn (ssh):Permission denied, please try again.
   EBU[0000] commandconn (ssh):ubuntu@192.168.1.11: Permission denied (publickey,password).
  DEBU[0000] commandconn: starting ssh with [-l ubuntu -- 192.168.1.11 docker system dial-stdio] 
   EBU[0000] commandconn (ssh):Permission denied, please try again.
   EBU[0000] commandconn (ssh):Permission denied, please try again.
   EBU[0000] commandconn (ssh):ubuntu@192.168.1.11: Permission denied (publickey,password).
  DEBU[0000] commandconn: starting ssh with [-l ubuntu -- 192.168.1.11 docker system dial-stdio] 
   EBU[0000] commandconn (ssh):Permission denied, please try again.
   EBU[0000] commandconn (ssh):Permission denied, please try again.
   EBU[0000] commandconn (ssh):ubuntu@192.168.1.11: Permission denied (publickey,password).
  DEBU[0000] commandconn: starting ssh with [-l ubuntu -- 192.168.1.11 docker system dial-stdio] 
   EBU[0000] commandconn (ssh):Permission denied, please try again.
   EBU[0000] commandconn (ssh):Permission denied, please try again.
   EBU[0000] commandconn (ssh):ubuntu@192.168.1.11: Permission denied (publickey,password).
  DEBU[0000] commandconn: starting ssh with [-l ubuntu -- 192.168.1.11 docker system dial-stdio] 
   EBU[0000] commandconn (ssh):Permission denied, please try again.
   EBU[0000] commandconn (ssh):Permission denied, please try again.
   EBU[0000] commandconn (ssh):ubuntu@192.168.1.11: Permission denied (publickey,password).
  ERRO[0000] Can't add file &lt;file&gt; to tar: io: read/write on closed pipe 
  ERRO[0000] Can't close tar writer: io: read/write on closed pipe 
  DEBU[0000] FIXME: Got an status-code for which error does not match any expected type!!!: -1  module=api status_code=-1
  error during connect: Post &quot;http://docker/v1.24/build?buildargs=%7B%7D&amp;cachefrom=%5B%5D&amp;cgroupparent=&amp;cpuperiod=0&amp;cpuquota=0&amp;cpusetcpus=&amp;cpusetmems=&amp;cpushares=0&amp;dockerfile=Dockerfile&amp;labels=%7B%7D&amp;memory=0&amp;memswap=0&amp;networkmode=default&amp;rm=1&amp;shmsize=0&amp;t=localhost%3A5000%2Fbackend%3Ae150d93&amp;target=&amp;ulimits=null&amp;version=1&quot;: write |1: broken pipe
  </code></pre>
  <p>I have moved past the original issue, but I'm now facing a separate issue that was raised in the comments about platform compatibility. I had to switch from Python 3.9 to Python 3.8 in the base image and also specified <code>--platform=&quot;linux/arm64&quot;</code> in the base image:</p>
  <pre><code>FROM --platform=&quot;linux/arm64&quot; python:3.8
  </code></pre>