I have a container that is running the Apache service in the foreground. I would like to be able to access the container from another shell in order to \"poke around\" insid
docker exec -t -i container_name /bin/bash
Will take you to the containers console.
On Windows 10, I have docker installed. I am running Jnekins on a container and I encountered the same error message. Here is a step by step guide to resolve this issue:
Step 1: Open gitbash and run docker run -p 8080:8080 -p 50000:50000 jenkins.
Step 2: Open a new terminal.
Step 3: Do "docker ps" to get list of the running container. Copy the container id.
Step 4: Now if you do "docker exec -it {container id} sh" or "docker exec -it {container id} bash" you will get an error message similar to " the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'"
Step 5: Run command " $winpty docker exec -it {container id} sh"
vola !! You are now inside the terminal.
The "nsinit" way is:
install nsinit
git clone git@github.com:dotcloud/docker.git
cd docker
make shell
from inside the container:
go install github.com/dotcloud/docker/pkg/libcontainer/nsinit/nsinit
from outside:
docker cp id_docker_container:/go/bin/nsinit /root/
use it
cd /var/lib/docker/execdriver/native/<container_id>/
nsinit exec bash
First step get container id:
docker ps
This will show you something like
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1170fe9e9460 localhost:5000/python:env-7e847468c4d73a0f35e9c5164046ad88 "./run_notebook.sh" 26 seconds ago Up 25 seconds 0.0.0.0:8989->9999/tcp SLURM_TASK-303337_0
1170fe9e9460
is the container id in this case.
Second, enter the docker :
docker exec -it [container_id] bash
so in the above case:
docker exec -it 1170fe9e9460 bash
nsenter
does that. However I also needed to enter a container in a simple way and nsenter didn't suffice for my needs. It was buggy in some occasions (black screen plus -wd flag not working). Furthermore I wanted to login as a specific user and in a specific directory.
I ended up making my own tool to enter containers. You can find it at: https://github.com/Pithikos/docker-enter
Its usage is as easy as
./docker-enter [-u <user>] [-d <directory>] <container ID>