Avatar of chalie001
chalie001
 asked on

how to connect to container

hi how do i connect to container i run this
cat Dockerfile
FROM oraclelinux:8

# Identify the maintainer of an image
LABEL version="0.0.1"
LABEL maitainer="mymail@gmail.com"

# Update the image to the latest packages
RUN  yum update -y
docker container run -d acor:0.01
7d9cf2791f24265fc659bfc1510f0c3882ab0869ff3a3b19245c06ede39e1895
docker@docker-VirtualBox:~/Documents/images$
docker@docker-VirtualBox:~/Documents/images$ docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED       STATUS                    PORTS                                                                                                                             NAMES
3821f1e4c8f9   cndkhuong/oracle19c:latest   "/bin/sh -c 'exec $O…"   2 weeks ago   Up 44 minutes (healthy)   0.0.0.0:1533->1521/tcp, :::1533->1521/tcp                                                                                         oracle19c_v
e5a0834cead7   cndkhuong/oracle19c:latest   "/bin/sh -c 'exec $O…"   3 weeks ago   Up 44 minutes (healthy)   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:49160->22/tcp, :::49160->22/tcp, 0.0.0.0:49162->8080/tcp, :::49162->8080/tcp   ags1


 docker exec -it 7d9cf2791f24265fc659bfc1510f0c3882ab0869ff3a3b19245c06ede39e1895 /bin/bash
Error response from daemon: Container 7d9cf2791f24265fc659bfc1510f0c3882ab0869ff3a3b19245c06ede39e1895 is not running
 ps -a
CONTAINER ID   IMAGE                                 COMMAND                  CREATED          STATUS                      PORTS                                                                                                                             NAMES
7d9cf2791f24   acor:0.01                             "/bin/bash"              11 minutes ago   Exited (0) 11 minutes ago                                                                                                                                     focused_matsumoto
ff171022102f   acor:0.01                             "/bin/bash"              38 minutes ago   Exited (0) 38 minutes ago                                                                                                                                     stoic_beaver
2746acf55cb0   686afcdb1861                          "/bin/sh -c 'yum upd…"   40 hours ago     Exited (1) 40 hours ago                                                                                                                                       objective_lalande
4fb32c4f2a59   686afcdb1861                          "/bin/sh -c 'apt-get…"   2 days ago       Exit


docker exec -it 7d9cf2791f24 /bin/bash
Error response from daemon: Container 7d9cf2791f24265fc659bfc1510f0c3882ab0869ff3a3b19245c06ede39e1895 is not running


i what to connect to container and do installation

LinuxLinux OS DevInstallationLinux DistributionsDocker

Avatar of undefined
Last Comment
Charlie Arehart

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Charlie Arehart

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
chalie001

ASKER
docker container run -d acor:0.01
40ada09e9fe29836c77e8cd765d685a40635a7c9571059a5105275a5026e7883
docker@docker-VirtualBox:~/Documents/images$ docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED       STATUS                   PORTS                                                                                                                             NAMES
3821f1e4c8f9   cndkhuong/oracle19c:latest   "/bin/sh -c 'exec $O…"   2 weeks ago   Up 6 minutes (healthy)   0.0.0.0:1533->1521/tcp, :::1533->1521/tcp                                                                                         oracle19c_v
e5a0834cead7   cndkhuong/oracle19c:latest   "/bin/sh -c 'exec $O…"   3 weeks ago   Up 6 minutes (healthy)   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:49160->22/tcp, :::49160->22/tcp, 0.0.0.0:49162->8080/tcp, :::49162->8080/tcp   ags1
docker@docker-VirtualBox:~/Documents/images$ docker ps -a
CONTAINER ID   IMAGE                                 COMMAND                  CREATED          STATUS                      PORTS                                                                                                                             NAMES
40ada09e9fe2   acor:0.01                             "/bin/bash"              14 seconds ago   Exited (0) 13 seconds ago                                                                                                                                     nostalgic_engelbart
7d9cf2791f24   acor:0.01                             "/bin/bash"              13 hours ago     Exited (0) 13 hours ago                                                                                                                                       focused_matsumoto
ff171022102f   acor:0.01                             "/bin/bash"              14 hours ago     Exited (0) 14 hours ago                                                                                                                                       stoic_beaver
2746acf55cb0   686afcdb1861                          "/bin/sh -c 'yum upd…"   2 days ago       Exited (1) 2 days ago                                                                                                                                         objective_lalande
4fb32c4f2a59   686afcdb1861                          "/bin/sh -c 'apt-get…"   3 days ago       Exited (127) 3 days ago                                                                                                                                       mystifying_mahavira
3b64acbcf9e6   tshifhiwadocker/react-image:latest    "nginx -g 'daemon of…"   2 weeks ago      Exited (0) 2 weeks ago                                                                                                                                        react-app
862e3c883c1f   tshifhiwadocker/calmis-image:latest   "/bin/sh -c 'exec ja…"   2 weeks ago      Exited (143) 2 weeks ago                                                                                                                                      calmis-app
3821f1e4c8f9   cndkhuong/oracle19c:latest            "/bin/sh -c 'exec $O…"   2 weeks ago      Up 6 minutes (healthy)      0.0.0.0:1533->1521/tcp, :::1533->1521/tcp                                                                                         oracle19c_v
8aa3af22935d   cndkhuong/oracle19c:latest            "/bin/sh -c 'exec $O…"   3 weeks ago      Exited (255) 3 weeks ago    0.0.0.0:46164->1521/tcp, :::46164->1521/tcp                                                                                       acor
721a38b3a3c7   cndkhuong/oracle19c:latest            "/bin/sh -c 'exec $O…"   3 weeks ago      Exited (255) 3 weeks ago    0.0.0.0:46163->1521/tcp, :::46163->1521/tcp                                                                                       aunt
f78ad5407f93   cndkhuong/oracle19c:latest            "/bin/sh -c 'exec $O…"   3 weeks ago      Created                                                                                                                                                       amui
e5a0834cead7   cndkhuong/oracle19c:latest            "/bin/sh -c 'exec $O…"   3 weeks ago      Up 6 minutes (healthy)      0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:49160->22/tcp, :::49160->22/tcp, 0.0.0.0:49162->8080/tcp, :::49162->8080/tcp   ags1
0dc58252c0a5   hello-world                           "/hello"                 3 weeks ago      Exited (0) 3 weeks ago                                                                                                                                        eager_herschel
docker@docker-VirtualBox:~/Documents/images$ docker logs 40ada09e9fe2
docker@docker-VirtualBox:~/Documents/images$


Charlie Arehart

Chalie, you offered nothing new in that response. You just repeated what you had done before: starting a container, finding it not listed in the ps, finding it listed in the ps -a as exited. As I said, you can't "connect" to a stopped container. I think you're wanting to find why it stopped, and that's where the docker logs command could help.

Can you please respond with words (not more commands and output), as to what you think of these answers I am offering? If they are "not working" for you, please do clarify.
chalie001

ASKER
am geting this error

docker 40ada09e9fe2 logs
docker: '40ada09e9fe2' is not a docker command.
See 'docker --help'


This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Charlie Arehart

Did you heed that last command? It would show you that yoy were simply mistaken and just need to put the container id at the end of the command, like in showed in my earlier comment, so "docker logs 40ada09e9fe2".
chalie001

ASKER
am geting empty
 docker ps -a
CONTAINER ID   IMAGE                                 COMMAND                  CREATED        STATUS                     PORTS                                                                                                                             NAMES
40ada09e9fe2   acor:0.01                             "/bin/bash"              8 hours ago    Exited (0) 8 hours ago                                                                                                                                       nostalgic_engelbart
7d9cf2791f24   acor:0.01                             "/bin/bash"              22 hours ago   Exited (0) 22 hours ago                                                                                                                                      focused_matsumoto
ff171022102f   acor:0.01                             "/bin/bash"              22 hours ago   Exited (0) 22 hours ago                                                                                                                                      stoic_beaver

docker logs 40ada09e9fe2
docker@docker-VirtualBox:~/Documents/images$

it return nothing
Charlie Arehart

Ok. But let's be clear: I've answered the question you asked. You cannot connect to a stopped container. You seemed initially not to realize it was stopped. 

And I offered the suggestion of using docker logs, in case it might show something to help understand why it had stopped. The fact that the image you're using shows nothing in its logs is an entirely different subject (having as much to do with how the image was made), which expands beyond your original question.

As such, you should consider creating a new question for that, if that's where you want to go with continued diagnosis.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.