JEMaddux
JEMaddux

Reputation: 303

How to get into an active docker container?

I've ssh'd into the production box where my docker containers where and was able to list them with docker ps.
I got a list of containers that looked like:

CONTAINER ID   IMAGE          COMMAND                 CREATED         STATUS         PORTS              NAMES
123456789012   postgres:9.5   "docker-entrypoint..."  6 minutes ago   Up 6 minutes   1234/tcp           post
rails1234567   rails_image    "/usr/bin/docker-e..."  23 hours ago    Up 23 hours    0.0.0.0:4000/tcp   rails_auto

I was trying to get into the rails_image using commands:
docker exec -it rails_image bash
docker exec -it rails_auto bash
docker exec -it rails1234567 bash

They are failing with error:
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"bash\": executable file not found in $PATH"

Upvotes: 0

Views: 704

Answers (1)

JEMaddux
JEMaddux

Reputation: 303

The problem was that bash wasn't installed in the docker container.
The correct command was:

docker exec -it rails1234567 sh

This worked because sh was installed in the container.

Upvotes: 2

Related Questions