Languages
[Edit]
EN

Docker - exit from container command line

1 points
Created by:
JustMike
3590

Hi, today I would like to show you how we can exit from docker container command line.

Solution 1:

We can use: ctrl+d

Solution 2:

We just need to enter:

exit

and we will loggout from docker container and we will be back in OS where we started docker command line.

Practical example

In below example:

  1. we loggin to docker container shell with cmd:
    docker exec -t -i auth-service-container /bin/sh
  2. we list all dir and files with ls -al
  3. we enter 'exit' command and we are back in Linux shell
[root@localhost ~]# docker exec -t -i auth-service-container /bin/sh
/ # ls -al
total 46116
drwxr-xr-x    1 root     root            42 Oct  8 15:06 .
drwxr-xr-x    1 root     root            42 Oct  8 15:06 ..
-rwxr-xr-x    1 root     root             0 Oct  8 15:06 .dockerenv
drwxr-xr-x    2 root     root          4096 May  9  2019 bin
drwxr-xr-x    5 root     root           340 Oct  8 15:06 dev
drwxr-xr-x    1 root     root            66 Oct  8 15:06 etc
drwxr-xr-x    2 root     root             6 May  9  2019 home
drwxr-xr-x    1 root     root           132 May 11  2019 lib
drwxr-xr-x    3 root     root            17 Oct  8 15:06 log
drwxr-xr-x    5 root     root            44 May  9  2019 media
drwxr-xr-x    2 root     root             6 May  9  2019 mnt
drwxr-xr-x    2 root     root             6 May  9  2019 opt
dr-xr-xr-x  210 root     root             0 Oct  8 15:06 proc
drwx------    1 root     root            52 Oct 15 12:17 root
drwxr-xr-x    2 root     root             6 May  9  2019 run
drwxr-xr-x    2 root     root          4096 May  9  2019 sbin
drwxr-xr-x    2 root     root             6 May  9  2019 srv
dr-xr-xr-x   13 root     root             0 Oct  8 12:24 sys
drwxrwxrwt    5 root     root           115 Oct  8 15:06 tmp
drwxr-xr-x    1 root     root            81 May 11  2019 usr
drwxr-xr-x    1 root     root            19 May  9  2019 var
/ # exit
[root@localhost ~]#

 

Hey 👋
Would you like to know what we do?
  • Dirask is online IT community for professionals and hobbyist to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.