Answers: <p>Containers may or may not include a shell, depending on how the container was built. Looking at <a href="https://hub.docker.com/r/portainer/base" rel="nofollow noreferrer">docker hub</a> it looks like the base image may be based on a &quot;scratch&quot; image, meaning that there may not be anything in the container other than the code needed to run the portainer service. The image layers <a href="https://hub.docker.com/layers/portainer/portainer-ce/latest/images/sha256-77917f339201db91aa25e9498bc130aaf46faa69d16c78088d422df85ce114b1?context=explore" rel="nofollow noreferrer">here</a> also suggest this is the case.</p>
  <p>If you want a shell, you may want to use the <code>portainer/portainer-ca:alpine</code> tag. That should give you a container with a full alpine os (and the shell you are looking for). As another note, you may want to try using <code>/bin/sh</code> instead as not all images provide a bash shell.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-01-12T15:50:51.490Z
Answers: 2021-01-12T15:50:51.490Z
Answers: Rhuarc13
Answers: <blockquote>
  <p>I thought each container had access to shell, and basic tools such as ls</p>
  </blockquote>
  <p>Only containers that have included a shell has support for a shell.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-01-10T19:55:58.307Z
Answers: 2021-01-10T19:55:58.307Z
Answers: Jonas
Answers: <p>While it is true that you can log in to most containers via /bin/bash or /bin/sh it isn't a general requirement to ship a working shell.  The official portainer docker container <a href="https://github.com/portainer/portainer/issues/2768#issuecomment-471365020" rel="nofollow noreferrer">does not have a shell for security reasons</a> according to <a href="https://github.com/itsconquest" rel="nofollow noreferrer">staff</a>.</p>
  <p>There are several things you can do.  One would be to build your own docker container image with a Dockerfile and include a shell.  If this is just for a one-off situation, you can also copy a shell (busybox looks like a good candidate) via <code>docker cp $(which busybox) portainer:/</code> followed by <code>docker exec -it portainer /busybox sh</code>.  This assumes that your running portainer container is indeed called &quot;portainer&quot;.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-11-01T10:39:50.460Z
Answers: 2021-11-01T10:39:50.460Z
Answers: leggewie
Body: <p>I cant connect to my running container with portainer.
  I tried already executing <code>docker exec -it &lt;CONTAINER-ID&gt; /bin/bash</code>. Also changed the shell path many times (/bin/sh, /usr/bin/sh, bash). Every time I get message:</p>
  <blockquote>
  <p>OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused &quot;exec: &quot;/bin/bash&quot;: stat /bin/bash: no such file or directory&quot;: unknown</p>
  </blockquote>
  <p>Container was created with command:</p>
  <pre><code>docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
  </code></pre>
  <p>Can you tell me why I can't connect to this container only? Portainer web interface is working fine... I thought each container had access to shell, and basic tools such as <code>ls</code></p>
  
Comments: CC BY-SA 4.0
Comments: 2021-01-10T19:51:40.540Z
Comments: If the container does not include `/bin/bash` then you can not start it with `docker exec`
Comments: Jonas
Tags: <docker>
Title: Cant ssh into running container containing portainer through docker exec
UserDisplayName: antonim
ThreadText: # Cant ssh into running container containing portainer through docker exec
  
  (Asked by: username_0 on 2021-01-10)
  
  I cant connect to my running container with portainer.
  I tried already executing `docker exec -it <CONTAINER-ID> /bin/bash`. Also changed the shell path many times (/bin/sh, /usr/bin/sh, bash). Every time I get message:
  
  > OCI runtime exec failed: exec failed: container\_linux.go:344: starting container process caused "exec: "/bin/bash": stat /bin/bash: no such file or directory": unknown
  
  Container was created with command:
  
  ```
  docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
  
  ```
  
  Can you tell me why I can't connect to this container only? Portainer web interface is working fine... I thought each container had access to shell, and basic tools such as `ls`
  
  **Tags:** docker
  
  > **Comments:**
  > **username_1**: If the container does not include `/bin/bash` then you can not start it with `docker exec`  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2021-01-12. Score: 2
  
  Containers may or may not include a shell, depending on how the container was built. Looking at [docker hub](https://hub.docker.com/r/portainer/base) it looks like the base image may be based on a "scratch" image, meaning that there may not be anything in the container other than the code needed to run the portainer service. The image layers [here](https://hub.docker.com/layers/portainer/portainer-ce/latest/images/sha256-77917f339201db91aa25e9498bc130aaf46faa69d16c78088d422df85ce114b1?context=explore) also suggest this is the case.
  
  If you want a shell, you may want to use the `portainer/portainer-ca:alpine` tag. That should give you a container with a full alpine os (and the shell you are looking for). As another note, you may want to try using `/bin/sh` instead as not all images provide a bash shell.
  
  
  ---
  
  ### Answer by username_3 on 2021-11-01. Score: 1
  
  While it is true that you can log in to most containers via /bin/bash or /bin/sh it isn't a general requirement to ship a working shell. The official portainer docker container [does not have a shell for security reasons](https://github.com/portainer/portainer/issues/2768#issuecomment-471365020) according to [staff](https://github.com/itsconquest).
  
  There are several things you can do. One would be to build your own docker container image with a Dockerfile and include a shell. If this is just for a one-off situation, you can also copy a shell (busybox looks like a good candidate) via `docker cp $(which busybox) portainer:/` followed by `docker exec -it portainer /busybox sh`. This assumes that your running portainer container is indeed called "portainer".
  
  
  ---
  
  ### Answer by username_1 on 2021-01-10. Score: 0
  
  > I thought each container had access to shell, and basic tools such as ls
  
  Only containers that have included a shell has support for a shell.
  
  
  ---
  
  