Docker provides framework to isolate an application and its dependencies into self-contained unit called containers. These containers can be run anywhere. Containers can be considered as “light” version of virtual machines.
In detached mode, container runs in background as a daemon.
1
2
3
4
5
6
7
8
9
10
# detached mode, with pseudo-tty. if pseudo-tty is not used, the container# will exit immediately after running as daemon# with -d container keeps running in background as daemon# -d Detached mode: Run container in the background# -t Allocate a pseudo-tty
docker run -t -d centos:6.8
# specifying container memory
docker run -t -d --memory="1g" centos:6.8
In interactive mode, containers run in foreground attached to local command line session.
1
2
3
4
5
# interactive mode# run container, attached interactively to local command line session and run /bin/bash# in this case, the container exits when we exit from /bin/bash
docker run -i -t centos:6.8 /bin/bash