Docker搭建开发环境
-
-
Save jackiect/18c54e81875e895902c5a642e11f53b1 to your computer and use it in GitHub Desktop.
Docker搭建开发环境
- apt-cacher-server,针对命令
apt-get install
- devpi,针对
pip install
- nexus,针对
mvn
docker build -t foundation/apt-cacher-ng:1.0.1 https://raw.githubusercontent.com/SvenDowideit/dockerfiles/4f8deb82ae9f78e95610cb8e49967384431e32b5/apt-cacher-ng/Dockerfile
docker run --name apt-cacher-ng -d -p 3142:3142 -v :/var/cache/apt-cacher-ng foundation/apt-cacher-ng:1.0.1
echo 'Acquire::http { Proxy "http://192.168.99.100:3142"; };' >> /etc/apt/apt.conf.d/01proxy
,Client机修改配置apt-get install -y vim
docker logs apt-cacher-ng
命令后,看到类似如下日志,说明成功了
1460687180|I|952925|172.17.0.1|httpredir.debian.org/debian/pool/main/v/vim/vim_7.4.488-7_amd64.deb
1460687180|O|952892|172.17.0.1|httpredir.debian.org/debian/pool/main/v/vim/vim_7.4.488-7_amd64.deb
- TODO:如果apt-cacher-server停掉了会发生什么?
docker pull scrapinghub/devpi
docker run -d --name devpi -p 3141:3141 -v :/mnt scrapinghub/devpi
- Client机修改配置
# ~/.pip/pip.conf
[global]
index-url = http://192.168.99.100:3141/root/pypi/+simple/
[install]
trusted-host = 192.168.99.100
[search]
index = http://192.168.99.100:3141/root/pypi/
# ~/.pydistutils.cfg
[easy_install]
index-url = http://192.168.99.100:3141/root/pypi/+simple/
- TODO:如果devpi-server停掉了会发生什么?
PS: devpi镜像中不包含devpi-web,http://192.168.99.100:3141/root/pypi/并不能响应get的http请求
有如下Dockerfile构件的image tryenv
FROM ubuntu
ENV myEnv=v0.1
RUN mkdir $myEnv
RUN echo RUN has myEnv=${myEnv} >> run.txt
CMD echo $myEnv && echo CMD has myEnv=$myEnv >> cmd.txt && bash
docker run --name tryenv0 -itd tryenv
, tryenv0中:日志第一行是v0.1
;有文件夹v0.1
;run.txt中的内容是RUN has myEnv=v0.1
;cmd.txt内容CMD has myEnv=v0.1
docker run --name tryenv1 -itd --env myEnv=v0.1.1 tryenv
, tryenv1中:日志第一行是v0.1.1
;会有文件夹v0.1
;run.txt中的内容是RUN has myEnv=v0.1
;cmd.txt内容CMD has myEnv=v0.1.1
- Docker运行时,使用一种叫Union File System的文件系统概念。Union File System包含2层:从image中继承而来的可读(read-only)层,和处于最顶部的读-写(read-write)层
- volumes是处在Union File System文件系统之外的一层
- Docker运行时,一旦配置了volumes,会事实在主机文件系统映射本地文件/文件夹,container对volumes的数据读写将直接反映在主机文件系统中
- volumes和主机文件的映射只可能在运行时实行,而不可能在
Dockerfile
中实现这种映射关系;常用的实现是通过docker run
命令的-v
参数,或docker-compose.yml
中配置 - 如果没有显示指定volume映射到主机的哪个文件/文件夹,docker在运行时会随机在主机新建一个文件夹与之映射;如果显示配置volumes映射关系,需要注意主机文件夹的读写权限问题
Dockerfile
中的VOLUMES
是一种配置方式而不是实现方式,且是隐式配置方式,而且Dockerfile中只能隐式配置- 不管怎样,可以通过命令
docker inspect -f {{.Mounts}} <container-id/container-name>
查看完整的映射
http://container-solutions.com/understanding-volumes-docker/
- alias apt-get='apt-get -o Acquire::http::proxy="http://mirrors.163.com/"' ## 搜狐源http://mirrors.sohu.com/ http://192.168.99.100:3142/
https://pypi.doubanio.com/simple/
http://mirrors.aliyun.com/pypi/simple/
http://192.168.99.100:3141/root/pypi/+simple/
isinstance(value, (tuple, list))
in python
url_for("/", filters=(1,2))
in ninja template
url_for("", filters=("v1", "v2")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dev-machine
Dockerfile