Recently heard that Docker is very hot, these two days to learn a bit. I am practical is the Mac OS operating system.
For information on what is the benefits of Docker, Docker, and installation, please refer to: http://tech.uc.cn/?p=2726
First, the basic command
1. Install Ubuntu virtual machine
Docker pull Ubuntu
2. View image
@~Docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL sizeubuntu latest 9bd07e480c5b 9 days ago 192.7 MB
3. Sign in to Ubuntu
Docker run-a stdin-a stdout-a stderr-i-T ubuntu/bin/ bash[email protected]:/# uname-3.16. 4-tinycore64 #1: x86_64 x86_64x86 _64 gnu/linux[email protected]:
Here's an explanation of the above command: Docker run-i-T <image>/bin/bash using image to create container and enter interactive mode, the login shell is/bin/bash
4, view container. After exiting Ubuntu, view
[Email protected]:/# exitexit@Docker PS-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESccaffb725895 ubuntu:latest "/bin/bash " 3 minutes ago Exited (0 seconds ago trusting_ Bohr
Ii. Preservation of container
If I log in to Ubuntu later to enter these commands is too cumbersome, need to lock container
1. Start container
@~ $ docker PS-acontainer ID IMAGE COMMAND CREATED STATUS PORTS NAMESccaffb725895 Ubuntu:latest "/bin/bash" 3 minutes ago Exited ( 0 the seconds ago Trusting_bohr @~docker start ccaffb725895ccaffb725895
2, attach
@~ $ docker start ccaffb725895ccaffb725895@~Docker attach ccaffb725895[email protected ]:/# [email protected]:/# uname-3.16. 4-tinycore64 #1: £ x86_64x86_ x86_64 gnu/linux[email protected]:
3. Save image, Commit command
@~$ docker imagesrepository TAG IMAGE ID CREATED VIRTUAL Sizeubuntu Latest 9BD07E480C5B9Days ago192.7mb@~ $Docker commit-a "Liqiu <[email protected]>" ccaffb725895 ubuntu:ssh- ubuntu5d2941e8c0bf7fe988604f11d043a03331ec83536ce09f841e760d51156b6865@~$ docker imagesrepository TAG IMAGE ID CREATED VIRTUAL Sizeubuntu ssh -ubuntu5D2941E8C0BF about a minute ago192.7Mbubuntu Latest 9bd07e480c5b9Days ago192.7MB
Third, delete container
@~ $ docker Stop ccaffb725895ccaffb725895@~ $ docker ps-acontainer ID IMAGE COMMAND created< C5/>status PORTS NAMESccaffb725895 ubuntu:latest "/bin/bash" minutes ago Exited (1275 minutes ago Trusting_bohr @~Docker rm ccaffb725895ccaffb725895@~ $ docker ps-acontainer ID IMAGE COMMAND CREATED STATUS PORTS names@
Iv. Recovery
After everything is calm, think of a problem, I installed a curl in the virtual machine, and I'll start it in a few days. Does curl still exist?
1. Go to Ubuntu and install Curl
@~ $ docker run-a stdin-a stdout-a stderr-i-t ubuntu/bin/bash[email protected]:/# sudo apt-install curl
2. After exiting, save the image
" Liqiu <[email protected]> " 0efb23b52565 ubuntu:curl-ubuntuaac468ce18c883bc71e849028a1718e57d80d3c6231840e6b1fdb4d66354bfe6@ ~ $ docker imagesrepository TAG IMAGE ID CREATED VIRTUAL sizeubuntu Curl-ubuntu Aac468ce18c8 About a minute ago 204.1 mbubuntu latest 9bd07e480c5b 9 days ago 192.7 MB
3. Re-enter the mirror
@~ $ docker imagesrepository TAG IMAGE ID CREATED VIRTUAL sizeubuntu Curl-ubuntu Aac468ce18c8 about a minute ago 204.1 mbubuntu latest 9bd07e480c5b 9 days ago 192.7 mb@~ $ docker run-a stdin-a stdout-a stderr-i-t aac468ce18c8/ bin/bash[email protected]:/# curl www.baidu.com<! DOCTYPE html> ..... .........
Finish the job! ~
Docker usage Notes