Mac下使用docker搭建STF(踩坑失败)

一、     docker 容器的安装:

1、 什么是docker?(摘自百度百科)

    Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。我的理解是docker就像一个虚拟机,可以在这里面跑一些应用。

2、Docker的下载:

访问官网:https://docs.docker.com/docker-for-mac/,下载的文件为Docker.dmg。

3、Docker的安装:

打开安装包

Mac下使用docker搭建STF(踩坑失败)_第1张图片

将Docker拖入Applications即可。

在Applications里打开Docker,看到欢迎界面,说明安装好了。

Mac下使用docker搭建STF(踩坑失败)_第2张图片

按照提示下一步最后会看到以下界面:

Mac下使用docker搭建STF(踩坑失败)_第3张图片

4、检查安装信息:

在终端输入:

      docker--version

docker version 17.06.0-ce, build 02c1d87

 

          docker-compose --version

docker-compose version 1.14.0, build c7bdf9e

 

      docker-machine--version

docker-machine version 0.12.0, build 45c69ad

 

5、检查是否能拉取镜像:

终端输入:

docker run hello-world

出现以下信息:

Hellofrom Docker!

Thismessage shows that your installation appears to be working correctly.

 

Togenerate this message, Docker took the following steps:

 1. The Docker client contacted the Dockerdaemon.

 2. The Docker daemon pulled the"hello-world" image from the Docker Hub.

 3. The Docker daemon created a new containerfrom that image which runs the

    executable that produces the output you arecurrently reading.

 4. The Docker daemon streamed that output tothe Docker client, which sent it

    to your terminal.

 

Totry something more ambitious, you can run an Ubuntu container with:

 $ docker run -it ubuntu bash

 

Shareimages, automate workflows, and more with a free Docker ID:

 https://cloud.docker.com/

 

Formore examples and ideas, visit:

 https://docs.docker.com/engine/userguide/

 

则说明拉取成功,可以进行下一步操作。

 

二、     使用docker搭建STF平台:

(一)、非完整版搭建:

1、这个方法需要先pull下来5个镜像:

在终端输入:

docker pull openstf/stf:latest

docker pull sorccu/adb:latest

docker pull rethinkdb:latest

docker pull openstf/ambassador:latest

docker pull nginx:latest

 

拉取这几个镜像后STF就可以直接运行了,不用安装各种依赖和各种工具,甚至也不用安装adb。

 

2、启动STF:

在终端输入:

#先启动一个数据库

docker run -d --name rethinkdb -v /srv/rethinkdb:/data --net hostrethinkdb rethinkdb --bind all --cache-size 8192 --http-port 8090

 

#再启动adb service

docker run -d --name adbd --privileged -v /dev/bus/usb:/dev/bus/usb --nethost sorccu/adb:latest

 

#再启动stf

docker run -d --name stf --net host openstf/stf stf local --public-ipyour-ip

 

这样就可以直接从7100端口访问了,pull过来的几个组建的功能:

(1)  openstf/stf是stf的主镜像。

(2)sorccu/adb是adb工具。

(3)rethinkdb是数据库。

(4)openstf/ambassador这个网络代理工具,是连接docker内部网络的一个工具,估计作者是基于ambassador官方镜像进行修改的,ambassador可以让不同dokcer之前以私有网络的方式进行连接,可以理解为虚拟网络,如果把所有的端口暴露在外面,这个东西也可以不要。

(5)nginx,这是一个web服务器反向代理工具, stf依赖它将不同的url转发到不同模块上,没有nginx,生产环境中的stf是肯定不能正常工作的。

 

 

ps:在输入以上命令前,需要先在docker中添加shared path,让docker知道去哪里找到这些文件。

点击docker图标下的

会出现如下界面:

Mac下使用docker搭建STF(踩坑失败)_第4张图片

在file sharing中添加需要用到的路径,否则会报错:

docker:Error response from daemon: Mounts denied:

The path /srv/stddf/nginx.conf is not shared from OS X and is not known toDocker.

 

 

反正目前我按照这个方法跑起来!

你可能感兴趣的:(Mac下使用docker搭建STF(踩坑失败))