sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
curl -s https://get.docker.io/gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install lxc-docker docker
➜ ~ sudo docker info [sudo] password for tp: Containers: 1 Images: 4 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 6 Dirperm1 Supported: true Execution Driver: native-0.2 Logging Driver: json-file Kernel Version: 3.16.0-44-generic Operating System: Ubuntu 14.10 CPUs: 4 Total Memory: 7.702 GiB Name: ubuntu ID: LOMF:BPSX:TEY4:HU4K:S5E3:H6UX:DUNQ:MFSG:UAIP:JMW5:HKEP:SQ2M WARNING: No swap limit support
檢查docker守護進程是否在運行node
➜ ~ sudo status docker [sudo] password for tp: docker start/running, process 18117
➜ ~ sudo docker run -i -t ubuntu /bin/bash [sudo] password for tp: root@5e2accdd4f7a:/# # 建立特定名稱的docker sudo docker run --name first-docker -i -t ubuntu /bin/bash
# 先獲取鏡像 ➜ tools sudo docker pull kalilinux/kali-linux-docker latest: Pulling from kalilinux/kali-linux-docker a4d244f4db27: Pull complete ff90a7782c43: Pull complete 426f69441115: Pull complete c4fad45aeb16: Pull complete e4c3a586e9ad: Pull complete 63ae5ac8df0f: Already exists Digest: sha256:9d50de0f7e4f9696f7b85896cad1d966d4fabcc47c75ed427705708a33b762b4 Status: Downloaded newer image for kalilinux/kali-linux-docker:latest # 建立kali-linux ➜ tools sudo docker run --name kali -t -i kalilinux/kali-linux-docker /bin/bash root@fe6c7da22c2e:/# uname -a Linux fe6c7da22c2e 3.16.0-44-generic #59-Ubuntu SMP Tue Jul 7 02:07:39 UTC 2015 x86_64 GNU/Linux # 更新源列表,因爲剛安裝的,vim都沒有,因此用nano進行編輯 #加入以下源,ctrl+o寫入ctrl+x退出 deb http://mirrors.ustc.edu.cn/kali kali main non-free contrib deb-src http://mirrors.ustc.edu.cn/kali kali main non-free contrib deb http://mirrors.ustc.edu.cn/kali-security kali/updates main contrib non-free # 刷新源列表 apt-get update # 安裝metasploit root@fe6c7da22c2e:/# apt-get install metasploit
root@5e2accdd4f7a:/# hostname 5e2accdd4f7a root@5e2accdd4f7a:/# cat /etc/hosts 172.17.0.2 5e2accdd4f7a 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters root@5e2accdd4f7a:/# vim bash: vim: command not found root@5e2accdd4f7a:/# apt-get install vim
➜ ~ sudo docker ps -a [sudo] password for tp: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5e2accdd4f7a ubuntu "/bin/bash" 6 minutes ago Up 6 minutes fervent_wozniak c5e16b9df2e5 ubuntu "/bin/bash" 25 minutes ago Up 7 minutes reverent_hoover
➜ ~ sudo docker attach reverent_hoover root@c5e16b9df2e5:/#
➜ ~ sudo docker top fervent_wozniak UID PID PPID C STIME TTY TIME CMD root 20254 18117 0 14:02 pts/16 00:00:00 /bin/bash
➜ ~ sudo docker stop reverent_hoover reverent_hoover ➜ ~ sudo docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f68e131bb9dc ubuntu "/bin/bash" 12 minutes ago Exited (0) 11 minutes ago first-docker 5e2accdd4f7a ubuntu "/bin/bash" 22 minutes ago Exited (2) 39 seconds ago fervent_wozniak c5e16b9df2e5 ubuntu "/bin/bash" 42 minutes ago Exited (0) 2 seconds ago reverent_hoover ➜ ~ sudo docker start reverent_hoover reverent_hoover ➜ ~ sudo docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f68e131bb9dc ubuntu "/bin/bash" 12 minutes ago Exited (0) 11 minutes ago first-docker 5e2accdd4f7a ubuntu "/bin/bash" 22 minutes ago Exited (2) 49 seconds ago fervent_wozniak c5e16b9df2e5 ubuntu "/bin/bash" 42 minutes ago Up 1 seconds reverent_hoover
➜ ~ sudo docker inspect reverent_hoover
➜ ~ sudo docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f68e131bb9dc ubuntu "/bin/bash" 15 minutes ago Exited (0) 14 minutes ago first-docker 5e2accdd4f7a ubuntu "/bin/bash" 26 minutes ago Exited (2) 4 minutes ago fervent_wozniak c5e16b9df2e5 ubuntu "/bin/bash" 45 minutes ago Up 3 minutes reverent_hoover ➜ ~ sudo docker rm first-docker first-docker ➜ ~ sudo docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5e2accdd4f7a ubuntu "/bin/bash" 26 minutes ago Exited (2) 4 minutes ago fervent_wozniak c5e16b9df2e5 ubuntu "/bin/bash" 46 minutes ago Up 3 minutes reverent_hoover # 刪除所有容器 sudo docker rm `docker ps -a -q`