tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Container Management > Docker > How to start Docker Container in Interactive mode

How to start Docker Container in Interactive mode

Author: Venkata Sudhakar

Docker is an open platform to develop, ship, and run containerized applications. It separates infra from application to ease application development and support anywhere development strategy. The below example shows how to start Docker Container in Interactive mode which allows us to run a Command inside the Container. Please note that the container exits as soon as the interactive command (env, free, df, bash) terminates.

01C:\>docker run -it ubuntu whoami
02root
03 
04C:\>docker run -it ubuntu env
05PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
06HOSTNAME=01b6a559b6bc
07TERM=xterm
08HOME=/root
09 
10C:\>docker run -it ubuntu free
11              total        used        free      shared  buff/cache   available
12Mem:        2013940      513408      145780        1088     1354752     1341100
13Swap:       1048572           0     1048572
14 
15C:\>docker run -it ubuntu df -kh
16Filesystem      Size  Used Avail Use% Mounted on
17overlay          63G  2.4G   58G   4% /
18tmpfs            64M     0   64M   0% /dev
19tmpfs           984M     0  984M   0% /sys/fs/cgroup
20shm              64M     0   64M   0% /dev/shm
21/dev/sda1        63G  2.4G   58G   4% /etc/hosts
22tmpfs           984M     0  984M   0% /proc/acpi
23tmpfs           984M     0  984M   0% /sys/firmware
24 
25C:\>docker run -it ubuntu /bin/bash
26root@121e662e558b:/# ls
27bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
28root@121e662e558b:/# exit
29exit
30 
31C:\>docker container ls
32CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
33 
34C:\>

 
  


  
bl  br