sobota, 14 lutego 2015

Docker - first look how to


Docker

docker run ubuntu - run ubuntu instance

docker run ubuntu echo 'marek borkowski' - execute command on dockUbuntu instance

docker run -i -t ubuntu bash - run bash shell on dockUbuntu intance


list docker process

root ~ # docker ps -a
CONTAINER ID        IMAGE               COMMAND                CREATED              STATUS                      PORTS               NAMES
6e199c080cf8        ubuntu:latest       "bash"                 About a minute ago   Exited (0) 59 seconds ago                       condescending_colden
c0c3e7dbee7b        ubuntu:latest       "echo 'marek borkows   2 minutes ago        Exited (0) 2 minutes ago                        loving_wozniak      
cb102d353c5a        ubuntu:latest       "/bin/bash"            2 minutes ago        Exited (0) 2 minutes ago



run something more on docker instance

start do something loop

root ~ # docker run -d ubuntu /bin/bash -c "while true; do echo hello world; date; sleep 1; done"
c8494d50aca84e12ac380c24bce4ff1dcd4254173be53568ccda68a236e9732e


root ~ # docker ps -a
CONTAINER ID        IMAGE               COMMAND                CREATED              STATUS                          PORTS               NAMES
c8494d50aca8        ubuntu:latest       "/bin/bash -c 'while   6 seconds ago        Up 6 seconds                                        tender_mccarthy      


root ~ # docker logs c8494d50aca8
hello world
Sat Feb 14 17:59:26 UTC 2015
hello world
Sat Feb 14 17:59:27 UTC 2015
hello world
Sat Feb 14 17:59:28 UTC 2015
hello world
Sat Feb 14 17:59:29 UTC 2015
hello world
Sat Feb 14 17:59:30 UTC 2015
hello world
Sat Feb 14

stop instance

 root ~ # docker ps -a
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS                      PORTS               NAMES
c8494d50aca8        ubuntu:latest       "/bin/bash -c 'while   11 minutes ago      Up 11 minutes                                   tender_mccarthy      

     
root ~ # docker stop c8494d50aca8

c8494d50aca8

root ~ # docker ps -a
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS                           PORTS               NAMES
c8494d50aca8        ubuntu:latest       "/bin/bash -c 'while   12 minutes ago      Exited (-1) About a minute ago                       tender_mccarthy      


remove existing intance:

root ~ # docker ps -a

CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS                       PORTS               NAMES
c8494d50aca8        ubuntu:latest       "/bin/bash -c 'while   22 minutes ago      Exited (-1) 11 minutes ago                       tender_mccarthy      
52b37c74ae04        ubuntu:latest       "/bin/bash -c 'while   24 minutes ago      Exited (1) 24 minutes ago                        suspicious_feynman  
6e199c080cf8        ubuntu:latest       "bash"                 30 minutes ago      Exited (0) 30 minutes ago                        condescending_colden
c0c3e7dbee7b        ubuntu:latest       "echo 'marek borkows   31 minutes ago      Exited (0) 31 minutes ago                        loving_wozniak      
cb102d353c5a        ubuntu:latest       "/bin/bash"            31 minutes ago      Exited (0) 31 minutes ago                        jolly_galileo        

root ~ # docker rm 52b37c74ae04
52b37c74ae04
root ~ # docker rm 6e199c080cf8
6e199c080cf8
root ~ # docker rm c0c3e7dbee7b
c0c3e7dbee7b
root ~ # docker rm cb102d353c5a
cb102d353c5a
root ~ #
root ~ #
root ~ # docker ps -a
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS                       PORTS               NAMES
c8494d50aca8        ubuntu:latest       "/bin/bash -c 'while   23 minutes ago      Exited (-1) 11 minutes ago                       tender_mccarthy

Brak komentarzy:

Prześlij komentarz