您的位置:首页 > 运维架构 > Docker

Docker - 在Windows7中安装Docker

2017-06-06 21:49 369 查看

安装docker

1 - Virtualization Support

Check whether virtualization support is enabled at BIOS via HAV detection tool

2 - Docker Toolbox
DockerToolbox-1.12.6

Included Components:

docker 1.12.6
docker-machine 0.8.2
docker-compose 1.9.0
Kitematic 0.12.0
Boot2Docker ISO 1.12.6
VirtualBox 5.1.10

3 - Run Docker Quickstart Terminal

Download Boot2Docker.iso manually from internet and store iso file at:
C:\Users\<user>\.docker\machine\cache


Run "Docker Quickstart Terminal".

##         .
## ## ##        ==
## ## ## ## ##    ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
\______ o           __/
\    \         __/
\____\_______/

docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com 
Start interactive shell

guowli@5CG450158J MINGW64 ~
$ docker version
Client:
Version:      1.12.6
API version:  1.24
Go version:   go1.6.4
Git commit:   78d1802
Built:        Wed Jan 11 00:23:16 2017
OS/Arch:      windows/amd64

Server:
Version:      1.13.1
API version:  1.26
Go version:   go1.7.5
Git commit:   092cba3
Built:        Wed Feb  8 08:47:51 2017
OS/Arch:      linux/amd64

guowli@5CG450158J MINGW64 ~
$
guowli@5CG450158J MINGW64 ~
$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.13.1

guowli@5CG450158J MINGW64 ~
$

docker-machine常用命令

docker-machine help # 查看帮助信息

active                # Print which machine is active
config                # Print the connection config for machine
create                # Create a machine
env                   # Display the commands to set up the environment for the Docker client
inspect               # Inspect information about a machine
ip                    # Get the IP address of a machine
kill                  # Kill a machine
ls                    # List machines
provision             # Re-provision existing machines
regenerate-certs      # Regenerate TLS Certificates for a machine
restart               # Restart a machine
rm                    # Remove a machine
ssh                   # Log into or run a command on a machine with SSH.
scp                   # Copy files between machines
start                 # Start a machine
status                # Get the status of a machine
stop                  # Stop a machine
upgrade               # Upgrade a machine to the latest version of Docker
url                   # Get the URL of a machine
version               # Show the Docker Machine version or a machine docker version
help                  # Shows a list of commands or help for one command

Run 'docker-machine COMMAND --help' for more information on a command.

通过SSH方式登录boot2docker

一般情况下,boot2docker的默认地址为192.168.99.100,SSH端口:22,默认的用户名和密码:
docker/tcuser


具体信息可通过Docker Quickstart Terminal执行相关命令查看和ssh登录。

但Docker Quickstart Terminal的复制粘贴较为繁琐,建议使用第三方ssh登录工具。

guowli@5CG450158J MINGW64 ~
$ docker-machine ip
192.168.99.100

guowli@5CG450158J MINGW64 ~
$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.13.1

guowli@5CG450158J MINGW64 ~
$ docker-machine ssh default
##         .
## ## ##        ==
## ## ## ## ##    ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
\______ o           __/
\    \         __/
\____\_______/
_                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.13.1, build HEAD : b7f6033 - Wed Feb  8 20:31:48 UTC 2017
Docker version 1.13.1, build 092cba3
docker@default:~$

在boot2docker中切换root用户

可以通过
sudo -i
方式切换成root用户

参考信息:http://stackoverflow.com/questions/32646952/docker-machine-boot2docker-root-password

$ docker-machine ssh default
docker@default:~$ sudo -i
Boot2Docker version 1.13.1, build HEAD : b7f6033 - Wed Feb  8 20:31:48 UTC 2017
Docker version 1.13.1, build 092cba3
root@default:

在boot2docker中设置代理

因网络访问限制导致无法拉取镜像:

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.

处理方法:在boot2docker的
/var/lib/boot2docker/profile
文件添加相应代理,然后重启docker。

例如:

$ docker-machine ssh default
docker@default:~$ sudo -i
Boot2Docker version 1.13.1, build HEAD : b7f6033 - Wed Feb  8 20:31:48 UTC 2017
Docker version 1.13.1, build 092cba3
root@default:~#
a707
vi /var/lib/boot2docker/profile
root@default:~# cat /var/lib/boot2docker/profile | tail -n 3
export HTTP_PROXY=http://10.144.1.10:8080
export HTTPS_PROXY=https://10.144.1.10:8080
export NO_PROXY=localhost,127.0.0.1,.nsn-net.net,.ext.net.nokia.com,.inside.nsn.com,.int.net.nokia.com,.inside.nokiasiemensnetworks.com
root@default:~#
root@default:~# exit
docker@default:~$ exit
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: