title: Docker error: standard_init_linux.go:228: exec user process caused: exec format error
body: <p>I was able to build a multiarch image successfully from an M1 Macbook which is arm64.
  Here's my docker file and trying to run from a raspberrypi aarch64/arm64 and I am getting this error when running the image: <strong>standard_init_linux.go:228: exec user process caused: exec format error</strong></p>
  <p>Editing the post with the python file as well:</p>
  <pre><code>FROM frolvlad/alpine-python3
  
  RUN pip3 install docker
  RUN mkdir /hoster
  WORKDIR /hoster
  ADD hoster.py /hoster/
  
  CMD [&quot;python3&quot;, &quot;-u&quot;, &quot;hoster.py&quot;]
  
  
  
  
  #!/usr/bin/python3
  import docker
  import argparse
  import shutil
  import signal
  import time
  import sys
  import os
  
  label_name = &quot;hoster.domains&quot;
  enclosing_pattern = &quot;#-----------Docker-Hoster-Domains----------\n&quot;
  hosts_path = &quot;/tmp/hosts&quot;
  hosts = {}
  
  def signal_handler(signal, frame):
      global hosts
      hosts = {}
      update_hosts_file()
      sys.exit(0)
  
  def main():
      # register the exit signals
      signal.signal(signal.SIGINT, signal_handler)
      signal.signal(signal.SIGTERM, signal_handler)
  
      args = parse_args()
      global hosts_path
      hosts_path = args.file
  
      dockerClient = docker.APIClient(base_url='unix://%s' % args.socket)
      events = dockerClient.events(decode=True)
      #get running containers
      for c in dockerClient.containers(quiet=True, all=False):
          container_id = c[&quot;Id&quot;]
          container = get_container_data(dockerClient, container_id)
          hosts[container_id] = container
  
      update_hosts_file()
  
      #listen for events to keep the hosts file updated
      for e in events:
          if e[&quot;Type&quot;]!=&quot;container&quot;: 
              continue
          
          status = e[&quot;status&quot;]
          if status ==&quot;start&quot;:
              container_id = e[&quot;id&quot;]
              container = get_container_data(dockerClient, container_id)
              hosts[container_id] = container
              update_hosts_file()
  
          if status==&quot;stop&quot; or status==&quot;die&quot; or status==&quot;destroy&quot;:
              container_id = e[&quot;id&quot;]
              if container_id in hosts:
                  hosts.pop(container_id)
                  update_hosts_file()
  
  
  def get_container_data(dockerClient, container_id):
      #extract all the info with the docker api
      info = dockerClient.inspect_container(container_id)
      container_hostname = info[&quot;Config&quot;][&quot;Hostname&quot;]
      container_name = info[&quot;Name&quot;].strip(&quot;/&quot;)
      container_ip = info[&quot;NetworkSettings&quot;][&quot;IPAddress&quot;]
      if info[&quot;Config&quot;][&quot;Domainname&quot;]:
          container_hostname = container_hostname + &quot;.&quot; + info[&quot;Config&quot;][&quot;Domainname&quot;]
      
      result = []
  
      for values in info[&quot;NetworkSettings&quot;][&quot;Networks&quot;].values():
          
          if not values[&quot;Aliases&quot;]: 
              continue
  
          result.append({
                  &quot;ip&quot;: values[&quot;IPAddress&quot;] , 
                  &quot;name&quot;: container_name,
                  &quot;domains&quot;: set(values[&quot;Aliases&quot;] + [container_name, container_hostname])
              })
  
      if container_ip:
          result.append({&quot;ip&quot;: container_ip, &quot;name&quot;: container_name, &quot;domains&quot;: [container_name, container_hostname ]})
  
      return result
  
  
  def update_hosts_file():
      if len(hosts)==0:
          print(&quot;Removing all hosts before exit...&quot;)
      else:
          print(&quot;Updating hosts file with:&quot;)
  
      for id,addresses in hosts.items():
          for addr in addresses:
              print(&quot;ip: %s domains: %s&quot; % (addr[&quot;ip&quot;], addr[&quot;domains&quot;]))
  
      #read all the lines of thge original file
      lines = []
      with open(hosts_path,&quot;r+&quot;) as hosts_file:
          lines = hosts_file.readlines()
  
      #remove all the lines after the known pattern
      for i,line in enumerate(lines):
          if line==enclosing_pattern:
              lines = lines[:i]
              break;
  
      #remove all the trailing newlines on the line list
      if lines:
          while lines[-1].strip()==&quot;&quot;: lines.pop()
  
      #append all the domain lines
      if len(hosts)&gt;0:
          lines.append(&quot;\n\n&quot;+enclosing_pattern)
          
          for id, addresses in hosts.items():
              for addr in addresses:
                  lines.append(&quot;%s    %s\n&quot;%(addr[&quot;ip&quot;],&quot;   &quot;.join(addr[&quot;domains&quot;])))
          
          lines.append(&quot;#-----Do-not-add-hosts-after-this-line-----\n\n&quot;)
  
      #write it on the auxiliar file
      aux_file_path = hosts_path+&quot;.aux&quot;
      with open(aux_file_path,&quot;w&quot;) as aux_hosts:
          aux_hosts.writelines(lines)
  
      #replace etc/hosts with aux file, making it atomic
      shutil.move(aux_file_path, hosts_path)
  
  
  def parse_args():
      parser = argparse.ArgumentParser(description='Synchronize running docker container IPs with host /etc/hosts file.')
      parser.add_argument('socket', type=str, nargs=&quot;?&quot;, default=&quot;tmp/docker.sock&quot;, help='The docker socket to listen for docker events.')
      parser.add_argument('file', type=str, nargs=&quot;?&quot;, default=&quot;/tmp/hosts&quot;, help='The /etc/hosts file to sync the containers with.')
      return parser.parse_args()
  
  if __name__ == '__main__':
      main()
  </code></pre>