Docker安装web
环境:windows7docker
安装包:DockerToolbox-17.10.0-ce.exe (下载地址:http://mirrors.aliyun.com/docker-toolbox/windows/docker-toolbox/)windows
坑:centos
//启动包错: Running pre-create checks... (default) No default Boot2Docker ISO found locally, downloading the latest release... //以后下载ISO 而后被墙。。。
缘由:其实这个报错不须要下载最新ISO文件,而是Boot2Docker文件没有放到正确的位置。浏览器
解决:复制安装目录下的boot2docker.iso到C:\Users\Administrator.Docker\machine\cache到这个目录下。ui
坑:this
//启动报错: Error creating machine: Error in driver during machine creation:This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory
缘由:BIOS没有开启虚拟化rest
解决:这时就要启动BIOS的虚拟化设置 | 开启CPU虚拟化支持。 重启电脑后按F2或F10进入BIOS界面(不一样主板型号进入BIOS所需按键不一样)。 进入BIOS界面:Intel Virtualization Technology > Enabled。code
端口映射教程
环境:windows7(Linux下可能不存在这个问题)
坑:
//在docker下部署了web应用服务并进行了端口映射。部署完成后,在浏览器中输入localhost:port没法访问对应的web服务
缘由:原来,docker是运行在Linux上的,在Windows中运行docker,实际上仍是在Windows下先安装了一个Linux环境,而后在这个系统中运行的docker。也就是说,服务中使用的localhost指的是这个Linux环境的地址,而不是咱们的宿主环境Windows。
解决:输入如下命令查找这个的Linux ip 使用这个ip地址加端口号(ip:port)访问web应用,访问成功。
#这个ip地址通常为192.168.99.100 docker-machine ip default
环境:windows7
坑: 使用docker build 建立新景象,写好Dockerfile后运行命令
$ docker build -t test/centos:6.7 .
#报如下错误
$ error checking context: 'can't stat '\\?\C:\Users\Administrator\AppData\Local\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application ...
缘由:Dockerfile保存位置不对。
解决:正确作法 建立dockerfiles文件夹并进入文件夹:
$ mkdir dockerfiles $ cd dockerfiles
建立并编辑Dockerfile文件:
$ touch Dockerfile $ vi Dockerfile
执行docker build 命令:
docker build -t test/centos:6.7 .
使用docker两天的感觉:必定要看官网文档(最好是英文),不要使用国内哪些所谓的教程!!!不要问我为何???(坑太多。。。)
坑: 使用swarm 新建集群时遇到双网卡,未指定IP 报如下错误
Error response from daemon: could not choose an IP address to advertise since this system has multiple addresses on different interfaces (10.0.2.15 on eth0 and 192.168.99.100 on eth1) - specify one with --advertise-addr
缘由:因为有两个IP,集群不知道使用哪一个因此报错。
解决:解决方法报错信息已经给出提示,使用--advertise-addr 指定IP
$docker swarm init --advertise-addr 192.168.99.100
坑: 使用 docker-compose.yml 运行docker 官网例子时报错
$docker stack deploy -c docker-compose.yml getstartedlab networks Additional property networks is not allowed #相似错误 replicas Additional property replicas is not allowed ...
缘由:docker-compose.yml文件缩进不正确
官网版本:
version: "3" services: web: # replace username/repo:tag with your name and image details image: username/repo:tag deploy: replicas: 5 resources: limits: cpus: "0.1" memory: 50M restart_policy: condition: on-failure ports: - "80:80" networks: - webnet networks: webnet:
个人版本
version: "3" services: web: # replace username/repo:tag with your name and image details image: username/repo:tag deploy: replicas: 5 resources: limits: cpus: "0.1" memory: 50M restart_policy: #缩进错误 condition: on-failure #缩进错误 ports: #缩进错误 - "80:80" #缩进错误 networks: #缩进错误 - webnet #缩进错误 networks: webnet:
解决:修改缩进错误,从新运行命令,一切正常。