docker ubuntu with bash promt , run , diff , attach , commit , logs


[root@wp ~]# docker run -i -t ubuntu:16.04 /bin/bash
Unable to find image 'ubuntu:16.04' locally
16.04: Pulling from library/ubuntu
9ff7e2e5f967: Pull complete
59856638ac9f: Pull complete
6f317d6d954b: Pull complete
a9dde5e2a643: Pull complete
Digest: sha256:cad5e101ab30bb7f7698b277dd49090f520fe063335643990ce8fbd15ff920ef
Status: Downloaded newer image for ubuntu:16.04
root@86f0f63d7549:/# hostname
86f0f63d7549



root@86f0f63d7549:/# id
uid=0(root) gid=0(root) groups=0(root)
root@86f0f63d7549:/#
root@86f0f63d7549:/# echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
root@86f0f63d7549:/# [root@wp ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
86f0f63d7549        ubuntu:16.04        "/bin/bash"         2 minutes ago       Up 2 minutes                            boring_driscoll
[root@wp ~]# docker attach boring_driscoll
root@86f0f63d7549:/#
root@86f0f63d7549:/# pwd
/
root@86f0f63d7549:/# ls
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr
root@86f0f63d7549:/# cd usr
root@86f0f63d7549:/usr# ls
bin  games  include  lib  local  sbin  share  src
root@86f0f63d7549:/usr# exit
exit
[root@wp ~]# docker run -i -t ubuntu:16.04 /bin/bash
root@4fb497c7f61b:/# cd /home
root@4fb497c7f61b:/home# ls -l
total 0
root@4fb497c7f61b:/home# touch {abc,cde,fgh}
root@4fb497c7f61b:/home# ls -l
total 0
-rw-r--r-- 1 root root 0 Jun 11 13:27 abc
-rw-r--r-- 1 root root 0 Jun 11 13:27 cde
-rw-r--r-- 1 root root 0 Jun 11 13:27 fgh
root@4fb497c7f61b:/home# exit
exit
[root@wp ~]# docker diff 4fb497c7f61b
C /home
A /home/abc
A /home/cde
A /home/fgh
C /root
A /root/.bash_history



[root@wp ~]# docker run -i -t ubuntu:16.04 /bin/bash
root@ce3b23806052:/# exit
[root@wp ~]# docker attach ce3b23806052
root@ce3b23806052:/#
root@ce3b23806052:/# while true; do date; sleep 5; done
Tue Jun 11 13:34:08 UTC 2019
Tue Jun 11 13:34:13 UTC 2019
Tue Jun 11 13:34:18 UTC 2019
Tue Jun 11 13:34:23 UTC 2019
Tue Jun 11 13:34:28 UTC 2019



[root@wp ~]# docker commit 1e57a0b057a9 earningdocker/ubuntu_wget
sha256:ace2e2fab401b8902d23858dbffb27e207e03f7803cb7d84d64033e152959965
root@wp ~]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED              SIZE
earningdocker/ubuntu_wget   latest              ace2e2fab401        About a minute ago   151MB
busybox                     latest              ef46e0caa533        15 hours ago         1.21MB
ubuntu                      16.04               2a697363a870        3 weeks ago          119MB
hello-world                 latest              fce289e99eb9        5 months ago         1.84kB
[root@wp ~]#



docker run -d ubuntu \
> /bin/bash -c "while true; do date; sleep 5; done"
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
6abc03819f3e: Pull complete
05731e63f211: Pull complete
0bd67c50d6be: Pull complete
Digest: sha256:f08638ec7ddc90065187e7eabdfac3c96e5ff0f6b2f1762cf31a4f49b53000a5
Status: Downloaded newer image for ubuntu:latest
fc2dd943d854f895d529131fd4e9d72e1995864c5d2e15facf2afeeeb9b48d30



sudo docker logs  fc2dd943d854f895d529131fd4e9d72e1995864c5d2e15facf2afeeeb9b48d30
Tue Jun 11 14:00:46 UTC 2019
Tue Jun 11 14:00:51 UTC 2019
Tue Jun 11 14:00:56 UTC 2019
Tue Jun 11 14:01:01 UTC 2019
Tue Jun 11 14:01:06 UTC 2019
Tue Jun 11 14:01:11 UTC 2019
Tue Jun 11 14:01:16 UTC 2019
Tue Jun 11 14:01:21 UTC 2019
Tue Jun 11 14:01:26 UTC 2019
Tue Jun 11 14:01:32 UTC 2019
Tue Jun 11 14:01:37 UTC 2019
Tue Jun 11 14:01:42 UTC 2019
Tue Jun 11 14:01:47 UTC 2019
Tue Jun 11 14:01:52 UTC 2019
Tue Jun 11 14:01:57 UTC 2019
Tue Jun 11 14:02:02 UTC 2019
Tue Jun 11 14:02:07 UTC 2019
Tue Jun 11 14:02:12 UTC 2019
Tue Jun 11 14:02:17 UTC 2019
Tue Jun 11 14:02:22 UTC 2019
Tue Jun 11 14:02:27 UTC 2019

Comments