Home > database >  Unable to go inside a running docker container
Unable to go inside a running docker container

Time:01-29

I am using ubuntu 22.04 lts as a sudo user.

I made a react application and then I created a image and ran it in a container successfully. But i want to go inside the container for which i ran the below command:

docker exec -it e448b7024af bash

but i got the following error:

Error response from daemon: Container e448b7024af19a0bb is not running

I ran the below command to check if container is running:

docker ps
// i got my container in the list
// also i did some actions in react application to double check if conatiner was working and it worked perfectly

below is the output for the above command:

CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                                       NAMES
56f8042d2f1   react_d   "docker-entrypoint.s…"   12 minutes ago   Up 12 minutes   0.0.0.0:3000->3000/tcp, :::3000->3000/tcp   youthful_sammet

then based on some other solution i tried the below command:

 docker run -it e448b7024af /bin/bash

and i got the following error:

Unable to find image 'e448b7024af:latest' locally
docker: Error response from daemon: pull access denied for e448b70254af, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.

then i tried the following command based on some solution i found:

docker pull e448b7024af:latest

but i got the following error:

Error response from daemon: pull access denied for e448b7024af, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

i also tried:

docker exec -it 568f8042d2f1 bash

and i got the following error:

OCI runtime exec failed: exec failed: unable to start container process: exec: "bash": executable file not found in $PATH: unknown

Below is my Dockerfile:

FROM node:alpine

WORKDIR /app

COPY /package*.json ./

RUN npm install

COPY . .

CMD ["npm","run","start"]

My container is working properly but i am unable to get inside of the container. Any help is appreciated. Thanks in advance.

CodePudding user response:

Based on the output from docker ps, your container id is 56f8042d2f1 and not e448b7024af which I suspect might be your image id or a container id from a previous run.

Another thing is that bash isn't installed in Alpine images by default. You can use sh instead.

You can use the more human-friendly container name of youthful_sammet in your command and do

docker exec -it youthful_sammet sh

or, if you prefer the id

docker exec -it 56f8042d2f1 sh

CodePudding user response:

you are using the wrong container identifier in the docker exec command as when you do docker ps the container id is different and you are using the wrong one. I personally use the container name as identifier it is easy to remember.

  • Related