---
slug: "docker-run-via-ssh-then-input-device-is-not-a-tty"
title: "When Running Docker via SSH and Encountering \"the input device is not a TTY\" Error, Add the -t Option"
description: "When trying to use the `docker run` command with SSH arguments and encountering the message \"ssh docker run the input device is not a TTY,\" you can resolve the issue by adding the `-t` option to the SSH command."
url: "https://www.ytyng.com/en/blog/docker-run-via-ssh-then-input-device-is-not-a-tty"
publish_date: "2022-06-12T02:55:49Z"
created: "2022-06-12T02:55:49Z"
updated: "2026-02-26T20:40:08.572Z"
categories: ["Docker", "Linux"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/970cf88b2430495abce8a408deddb710.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# When Running Docker via SSH and Encountering "the input device is not a TTY" Error, Add the -t Option

<p>When you want to start an interactive program using TTY on a remote server with the following command:</p>
<pre>docker run --rm -it &lt;image-name&gt; /bin/sh</pre>
<p>you can do so without any issues by first executing:</p>
<pre>ssh &lt;user&gt;@&lt;remote-server&gt;</pre>
<p>and then, once the remote shell is initiated, running:</p>
<pre>docker run --rm -it &lt;image-name&gt; /bin/sh</pre>
<p>This allows you to use the TTY-based program on Docker without any problems.</p>
<p>However, if you attempt to run both SSH and the Docker run command in one go from your local machine (e.g., Mac), like this:</p>
<pre>ssh &lt;user&gt;@&lt;remote-server&gt; -- docker run --rm -it &lt;image-name&gt; /bin/sh</pre>
<p>you will encounter an error:</p>
<pre>ssh docker run the input device is not a TTY</pre>
<p>In such cases, you can resolve the issue by adding the <code>-t</code> option to the <code>ssh</code> command.</p>
<p></p>
<pre>ssh <strong>-t</strong> &lt;user&gt;@&lt;remote-server&gt; -- docker run --rm -it &lt;image-name&gt; /bin/sh</pre>
<p>And that’s it!</p>
