how do I login to a container as root?

thufir@dur:~$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              20c44cd7596f        2 days ago          123MB
hello-world         latest              725dcfab7d63        2 weeks ago         1.84kB
jmar71n/freepbx     latest              8dda2a58fde1        19 months ago       1.54GB
thufir@dur:~$ sudo docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
a2e7e9f60643        hello-world         "bash"              2 minutes ago       Created                                        laughing_knuth
b616192b64f4        ubuntu              "bash"              5 minutes ago       Exited (0) 5 minutes ago                       nifty_kowalevski
28237032f2d3        jmar71n/freepbx     "/sbin/my_init"     24 minutes ago      Up 24 minutes                                  wonderful_wilson
54c683990ccc        jmar71n/freepbx     "/sbin/my_init"     26 minutes ago      Up 26 minutes                                  modest_yalow
a91a6dcb8436        jmar71n/freepbx     "/sbin/my_init"     2 hours ago         Up 2 hours                                     gallant_noether
ac53b46b768e        ubuntu              "bash"              24 hours ago        Exited (0) 24 hours ago                        mystifying_murdock
b59af1daa216        hello-world         "/hello"            24 hours ago        Exited (0) 24 hours ago                        flamboyant_curie
thufir@dur:~$ sudo docker exec -u 0 -it jmar71n/freepbx bash
Error: No such container: jmar71n/freepbx
thufir@dur:~$ sudo docker exec -u 0 -it 8dda2a58fde1 bash
Error: No such container: 8dda2a58fde1

I can sorta login to one of the containers:

thufir@dur:~$ sudo docker run -it ubuntu bash
root@b616192b64f4:/# exit
thufir@dur:~$ sudo docker run -it jar71n/freepbx bash
Unable to find image 'jar71n/freepbx:latest' locally
docker: Error response from daemon: repository jar71n/freepbx not found: does not exist or no pull access.
See 'docker run --help'.

although the ubuntu image seems quite minimal. Want to login to any of the above containers.


seems you are spelling wrong the container name:

jar71n != jmar71n

  • what's the difference betweent the exec and run above? It looked like exec was the way to login -- will have to re-check that. – Thufir Nov 20 '17 at 11:34
  • 1
    Not sure, I had used docker just for learning and fun but I think you only can exec things into running containers. – Drymartini Nov 20 '17 at 11:35
  • 1
    If you don't explicitly tell docker to run something in background onto the container it finish itself after you call it so you need to run it again to log in – Drymartini Nov 20 '17 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.