title: Docker run fails error ' Extra argument XXX'
body: <p>I am trying to run my local docker file/docker compose setup. </p>
  
  <p>I get the following error. </p>
  
  <pre><code>docker-compose.exe up
  Starting docker_sshd_1 ... done
  Attaching to docker_sshd_1
  sshd_1  | Extra argument /usr/sbin/sshd.
  docker_sshd_1 exited with code 1
  </code></pre>
  
  <p>When I look a the logs</p>
  
  <pre><code>docker logs 76d6c9682749
  Extra argument /usr/sbin/sshd.
  </code></pre>
  
  <p>When I try to start or run it </p>
  
  <pre><code>docker start -ai 76d6c9682749
  Extra argument /usr/sbin/sshd.
  </code></pre>
  
  <p>Docker ps-a shows</p>
  
  <pre><code>docker ps -a
  CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS                      PORTS               NAMES
  76d6c9682749        ansible-test:latest   "/usr/sbin/sshd -D -…"   17 seconds ago      Exited (1) 15 seconds ago                       docker_sshd_1
  </code></pre>
  
  <p>docker-compose up --build</p>
  
  <pre><code>docker-compose.exe up --build
  Building sshd
  Step 1/6 : FROM ubuntu:18.04
  ---&gt; 1d9c17228a9e
  Step 2/6 : RUN apt-get update &amp;&amp; apt-get install -y                         net-tools                         netcat                         openssh-server                         curl
  ---&gt; Using cache
  ---&gt; a1c69db6f87d
  Step 3/6 : RUN mkdir /var/run/sshd &amp;&amp;     echo 'root:ansibletest' | chpasswd &amp;&amp;     echo '\n#allow root\nPermitRootLogin yes\n' &gt;&gt; /etc/ssh/sshd_config
  ---&gt; Using cache
  ---&gt; 8af61a1ff284
  Step 4/6 : EXPOSE 22
  ---&gt; Using cache
  ---&gt; 7483e7b442b4
  Step 5/6 : CMD ["/usr/sbin/sshd", "-D" ]
  ---&gt; Using cache
  ---&gt; 67634af48cd9
  Step 6/6 : ENTRYPOINT ["/usr/sbin/sshd", "-D", "-d"]
  ---&gt; Running in 304247678be0
  Removing intermediate container 304247678be0
  ---&gt; e8c85c2deea0
  Successfully built e8c85c2deea0
  Successfully tagged ansible-test:latest
  Recreating docker_sshd_1 ... done
  Attaching to docker_sshd_1
  sshd_1  | Extra argument /usr/sbin/sshd.
  docker_sshd_1 exited with code 1
  </code></pre>
  
  <p>Docker inspect shows the following for path and args</p>
  
  <pre><code>λ docker inspect --format='{{.Path}}' e8c85c2deea0
  '/usr/sbin/sshd'
  
  λ docker inspect --format='{{.Args}}' e8c85c2deea0
  '[-D /usr/sbin/sshd -D]'
  </code></pre>
  
  <p>my docker compose file looks like this</p>
  
  <pre><code>version: '3'
  services:
    sshd:
      build: .
      image: ansible-test:latest
      ports:
      - "2022:22" # bines local port 2022 to container port 22 / sshd
      - "8080:80" # binds local port 8080 to container port 80 / httpd
  </code></pre>
  
  <p>My docker file looks like this</p>
  
  <pre><code># borrowed https://docs.docker.com/engine/examples/running_ssh_service/
  FROM ubuntu:18.04
  
  # some useful debuging tools to troubleshoot on these containers
  RUN apt-get update &amp;&amp; apt-get install -y \
                          net-tools \
                          netcat \
                          openssh-server \
                          curl
  
  # configure sshd to work as we need it in 18.04
  # sets the rootpassword to ansibletest
  RUN mkdir /var/run/sshd &amp;&amp; \
      echo 'root:ansibletest' | chpasswd &amp;&amp; \
      echo '\n#allow root\nPermitRootLogin yes\n' &gt;&gt; /etc/ssh/sshd_config
  
  EXPOSE 22
  
  ENTRYPOINT ["/usr/sbin/sshd", "-D" ]
  #ENTRYPOINT ["/usr/sbin/sshd", "-D", "-d"]
  # for production system remove "-d"
  #  -D      When this option is specified, sshd will not detach and does not become a daemon.
  #          This allows easy monitoring of sshd.
  #  -d      Debug mode.  The server sends verbose debug output to standard error, and does not put itself in the background.
  #          The server also will not fork and will only process one connection.
  #          This option is only intended for debugging for the server.
  #          Multiple -d options increase the debugging level.  Maximum is 3.
  
  # by default start sshd as background daemon
  CMD ["/usr/sbin/sshd", "-D" ]
  # used for debugging lets you pass options to sshd on startup
  #CMD ["/usr/sbin/sshd", "-D", '-d']
  </code></pre>