Installing Docker
[[email protected] ~]# yum-y install Docker
Start Docker
[[email protected] ~]# Systemctl start Docker
Download the Docker machine binaries and unzip them to path
[Email protected] ~]# curl-l https://github.com/docker/machine/releases/download/v0.12.2/ docker-machine-' uname-s '-' uname-m ' >/tmp/docker-machine &&chmod +x/tmp/docker-machine && /tmp/docker-machine/usr/local/bin/docker-machine
Check the installation version
[Email protected] ~]# Docker-machine version
Docker-machine version 0.12.2, build 9371605
Create a virtual machine
Command
Docker-machine create-d VirtualBox VMname
If you experience the following issues
[Email protected] ~]# docker-machine create-d virtualbox VMname/root/.docker/machine/certs//root/ . docker/machine/certs/cert.pemrunning Pre-Create Checks ... Error with pre -create Check: "Vboxmanage not found. Make sure VirtualBox is installed
And Vboxmanage is in the path "
Upload the installation package,
Link: http://pan.baidu.com/s/1slpxvzv Password: qrlk
Install dependencies and install VirtualBox
[Email protected] ~]# yum-y localinstall virtualbox-5.1-5.1. 20_114628_el7-1
Create again
[Email protected] ~]# docker-machine create-d VirtualBox VMname
View the new machine
[[email protected] ~]# docker-machinelsname ACTIVE DRIVER State URL SWARM dockerors default - VMname Running tcp://192.168.99.100:2376 v17.0
Get environment information for a new virtual machine
[Email protected] ~]# Docker-machine env VMnameExport Docker_tls_verify="1"Export Docker_host="tcp://192.168.99.100:2376"Export Docker_cert_path="/root/.docker/machine/machines/default"Export Docker_machine_name="default"# Run Thiscommand to configure your shell: # eval $ (Docker-machine envdefault)
Import the host's environment variables into the created virtual machine
[[Email protected] ~]# eval $ (docker-machine env VMname)
View Virtual Machine IP
[Email protected] ~]# docker-machine IP VMname
View all virtual machines and IPs
[[email protected] ~]# Docker-machine ls
Go to the newly created virtual machine
[[email protected] ~]# docker-machine ssh VMname
Download Nginx image
[Email protected]:~$ Docker Pull Nginx
Installing Nginx
[Email protected]:~$ Docker run-d-P 8000:80--name nginx01 Nginx
You can also install Nginx outside the virtual machine
[Email protected] ~]# docker-machine ssh vmnaem8000:--name nginx01 nginx
Access Nginx
[[email protected] ~]# docker-machine ssh VMname curl-i192.168.99.101:8000HTTP/1.1 $Okserver:nginx/1.13.3Date:sat, GenevaSep . the: the: +gmtcontent-type:text/htmlcontent-length:612 Last-modified:tue, OneJul . -: .: -Gmtconnection:keep-Aliveetag:"5964cd3f-264"Accept-ranges:bytes% Total% Received%xferd Average Speed time time dload Upload Total spent left Speed0 612 0 0 0 0 0 0--:--:-- --:--:-- --:--:--0
Start
[Email protected] ~]# docker-machine start VMname
Stop it
[Email protected] ~]# docker-machine stop VMname
Restart
[Email protected] ~]# docker-machine restart VMname
Docker Machine (Docker VM)