Docker

来源:互联网 发布:java语言程序设计 一 编辑:程序博客网 时间:2024/06/10 16:55

安装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.100For help getting started, check out the docs at https://docs.docker.comStart interactive shellguowli@5CG450158J MINGW64 ~$ docker versionClient: 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/amd64Server: 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/amd64guowli@5CG450158J MINGW64 ~$guowli@5CG450158J MINGW64 ~$ docker-machine lsNAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORSdefault   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.13.1guowli@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 ip192.168.99.100guowli@5CG450158J MINGW64 ~$ docker-machine lsNAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORSdefault   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.13.1guowli@5CG450158J MINGW64 ~$ docker-machine ssh default                        ##         .                  ## ## ##        ==               ## ## ## ## ##    ===           /"""""""""""""""""\___/ ===      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~           \______ o           __/             \    \         __/              \____\_______/ _                 _   ____     _            _| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ ||_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|Boot2Docker version 1.13.1, build HEAD : b7f6033 - Wed Feb  8 20:31:48 UTC 2017Docker version 1.13.1, build 092cba3docker@default:~$

在boot2docker中切换root用户

可以通过sudo -i方式切换成root用户
参考信息:http://stackoverflow.com/questions/32646952/docker-machine-boot2docker-root-password

$ docker-machine ssh defaultdocker@default:~$ sudo -iBoot2Docker version 1.13.1, build HEAD : b7f6033 - Wed Feb  8 20:31:48 UTC 2017Docker version 1.13.1, build 092cba3root@default:

在boot2docker中设置代理

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

$ docker run hello-worldUnable to find image 'hello-world:latest' locallyC:\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 defaultdocker@default:~$ sudo -iBoot2Docker version 1.13.1, build HEAD : b7f6033 - Wed Feb  8 20:31:48 UTC 2017Docker version 1.13.1, build 092cba3root@default:~# vi /var/lib/boot2docker/profileroot@default:~# cat /var/lib/boot2docker/profile | tail -n 3export HTTP_PROXY=http://10.144.1.10:8080export HTTPS_PROXY=https://10.144.1.10:8080export NO_PROXY=localhost,127.0.0.1,.nsn-net.net,.ext.net.nokia.com,.inside.nsn.com,.int.net.nokia.com,.inside.nokiasiemensnetworks.comroot@default:~# root@default:~# exitdocker@default:~$ exit
原创粉丝点击