Install Docker under Windows 7
1, download Docker Toolbox, download address: Https://www.docker.com/products/docker-toolbox
2, the default installation Docker toolbox can
3, after installation, start Docker Toolbox terminal, waiting for the configuration to end, display the virtual machine IP address, appear command character $
Note: 1 Error with Pre-create check: "This Computer doesn ' t have vt-x/amd-v enabled." Enabling it in the BIOS is mandatory ", you need to go to BIOS to open VT
2 if the Boot2docker.iso download fails, you can download the https://github.com/boot2docker/boot2docker/releases/download/v1.12.6/manually Boot2docker.iso, then put it in the C:\Users\Administrator\.docker\machine\cache\ directory.
4. Execute Order Confirmation
#查看版本
Docker version
#查看信息
Docker info
5, enter the virtual machine
1 command line to enter the virtual machine, default Docker account
Docker-machine SSH Default
#切换root权限
Sudo-i
2 SECURECRT connection Virtual machine 192.168.99.100, account Docker password Tcuser
6, Image acceleration
Docker-machine SSH Default
sudo sed-i "s| Extra_args= ' | Extra_args= '--registry-mirror= accelerated address |g '/var/lib/boot2docker/profile
Exit
Docker-machine Restart Default
7. Download image
Docker Pull Centos:latest
8. Start Mirror
Docker run--restart always--privileged-dit--name centoslatest Docker.io/centos:latest/bin/bash
9. Enter Virtual machine locally
Docker-machine ssh default
sudo-i
#增加新IP, eth1 for 192.168.99.101 network card
ifconfig eth1:0 192.168.99.101 netmask 255.255.255.0 up
echo "Ifconfig eth1:0 192.168.99.101 netmask 255.255.255.0 up ">>/opt/bootlocal.sh
#查看容器IP
Docker inspect-f ' {{. networksettings.ipaddress} ' centoslatest
#增加转发, 192.168.99.101 for new address, 172.17.0.2 for container IP
iptables-t nat-a prerouting-d 192.168.99.101-j dnat--to-destination 172.17.0.2 iptables-t nat-a postrouting-d 172.17.0.2-j SNAT
--to 172.17.0.1
#开启IP转发
echo 1 >/proc/sys/net/ipv4/ip_forward
echo "Net.ipv4.ip_forward = 1" > >/etc/sysctl.conf
sysctl-p
#防火墙开启转发
iptables-f
access to the container 192.168.99.101
Second, Redhat 7.X installation Docker
1, confirm kernel version uname-r, version 3.10 above
2. Modify Yum Source
3, Yum Install-y Docker
4, Image acceleration
sudo cp/lib/systemd/system/docker.service/lib/systemd/system/docker.service.bak
sudo sed-i "s|\ (execstart=/usr/bin/docker[^]*\) |\1--registry-mirror=" accelerated Address "|g"/lib/systemd/system/docker.service
5. Reload Configuration
sudo systemctl daemon-reload
6. Start Docker Service
sudo service docker start
7. Download image
Docker Pull Centos:latest
8, start the container
Docker run--restart always--privileged-dit--name centoslatest Docker.io/centos:latest/bin/bash
9. Enter the container
Docker attach <name or CONTAINER id>
Using [Ctrl + D], this will end Docker the current thread, the end of the container, you can use [Ctrl + P][ctrl + Q] to exit without terminating the container to run
Toggle Root Permissions
Sudo-i
10, increase the independent IP
Sudo-i
#增加新IP, eth1 for 192.168.1.10 network card
ifconfig eth1:0 192.168.1.10 netmask 255.255.255.0 up
#永久增加虚拟网卡
echo-e "device=eth0:0\nbootproto=static\nipaddr= 192.168.1.10\nnetmask=255.255.255.0\nonboot=yes ">/etc/sysconfig/network-scripts/ifcfg-eth0:0
sudo/etc/ init.d/networking Restart
#查看容器IP
Docker inspect-f ' {{. networksettings.ipaddress} ' centoslatest
#增加转发, 192.168.1.10 for new address, 172.17.0.2 for container IP
iptables-t nat-a prerouting-d 192.168.1.10-j dnat--to-destination 172.17.0.2 iptables-t nat-a postrouting-d 172.17.0.2-j SNAT
-- To 172.17.0.1
#开启IP转发
echo 1 >/proc/sys/net/ipv4/ip_forward
echo "Net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl-p
#防火墙开启转发
iptables-f
Access the container at this access 192.168.1.10
Third, the container configuration
1, SSH installation
Yum install-y openssh-server
ssh-keygen-q-t rsa-b 2048-f/etc/ssh/ssh_host_rsa_key-n '
ssh-keygen-q-t ECD Sa-f/etc/ssh/ssh_host_ecdsa_key-n '
ssh-keygen-t dsa-f/etc/ssh/ssh_host_dsa_key- n '
sed-i ' s/#UsePr Ivilegeseparation.*/useprivilegeseparation no/g "/etc/ssh/sshd_config
sed-i s/usepam.*/usepam no/g"/etc/ssh/ Sshd_config
#/usr/sbin/sshd-d
service sshd start
2. Basic software
Yum install-y vim wget Curl sudo passwd OpenSSL
#ifconfig
Yum Install-y net-tools.x86_64
#lsb_release
Yum Install-y redhat-lsb
3, other environmental configuration
4. Submit Mirror
Docker commit <container ID or name>
Docker commit Centoslatest centosimage:last.20170208
5, Save the Mirror
sudo docker save <image id> > < path >
sudo docker save centosimage:last.20170208 >/opt/centosimage:last.20170208.tar
6, restore the mirror
Docker Load < < path >
Docker Load </opt/centosimage:last.20170208.tar
Iv. Other common commands
# See all the containers
sudo docker ps-a
# Delete Container
sudo docker rm <container id>
# View All Mirrors
sudo docker images
# Delete Mirror
sudo docker rmi <image id>
#一次性删除所有的容器
Docker RM $ (Docker ps-q-a)
#一次性删除所有的镜像
Docker RMI $ (Docker images-q)
# Show all layers of the mirror (layer)
sudo docker images--tree
#导出容器
sudo docker export [CONTAINER ID] > [path]
Smaller than save mirror
#导入容器
Cat < path > | sudo docker import-<container id>
#查看容器进程
Docker Inspect-f "{{. State.pid}} "<container id>
#查看容器IP
Docker Inspect-f ' {{. Networksettings.ipaddress}} ' <container id>