标签:
安装docker
https://docs.docker.com/mac/
启动docker环境
launchpad -> Docker Quickstart Terminal
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
docker is configured to use the default machine with IP 192.168.99.101
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
查看已有虚拟机环境
wei:xcp_esms (develop)admin$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.101:2376 v1.10.1
dev - virtualbox Running tcp://192.168.99.100:2376 Unknown Unable to query docker version: Get https://192.168.99.100:2376/v1.15/version: x509: certificate is valid for 192.168.99.101, not 192.168.99.100
删除docker虚拟机
wei:xcp_esms (develop)admin$ docker-machine rm dev
About to remove dev
Are you sure? (y/n): y
Successfully removed dev
创建docker虚拟机
wei:xcp_esms (develop)admin$ docker-machine create --driver virtualbox --engine-insecure-registry 192.168.40.73:5001 dev
Running pre-create checks...
启动docker虚拟机
wei:xcp_esms (develop)admin$ docker-machine start dev
Starting "dev"...
Machine "dev" is already running.
wei:xcp_esms (develop)admin$ docker-machine env dev
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.102:2376"
export DOCKER_CERT_PATH="/Users/admin/.docker/machine/machines/dev"
export DOCKER_MACHINE_NAME="dev"
# Run this command to configure your shell:
# eval $(docker-machine env dev)
查看docker虚拟机运行信息
wei:xcp_esms (develop)admin$ eval $(docker-machine env dev)
查看docker镜像
wei:xcp_esms (develop)admin$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
获取镜像
wei:xcp_esms (develop)admin$ docker pull 192.168.40.73:5001/django:1.8.7
1.8.7: Pulling from django
5f70bf18a086: Pull complete
00b3806ef847: Pull complete
a9e0e5075443: Pull complete
f51da0171fb8: Pull complete
94cc93826def: Pull complete
f8c763ed9bc8: Pull complete
Digest: sha256:bf494210a1a42501c73c307113864e3e693aac8ed6d21c008d7c2082c0c65eee
Status: Downloaded newer image for 192.168.40.73:5001/django:1.8.7
查看本地镜像
wei:xcp_esms (develop)admin$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.40.73:5001/django 1.8.7 e0a79536098c 11 hours ago 522.1 MB
运行django项目
1)将本地路径映射到docker容器 /Users/admin/git/dj18/pad_math2_api:/code
2)在docker容器中运行服务 192.168.40.73:5001/django:1.8.7 python /code/esms/manage.py runserver 0.0.0.0:8080
wei:xcp_esms (develop)admin$ docker run -it --rm --net=host -v /Users/admin/git/dj18/pad_math2_api:/code 192.168.40.73:5001/django:1.8.7 python /code/esms/manage.py runserver 0.0.0.0:8080
Performing system checks...
System check identified no issues (0 silenced).
May 05, 2016 - 20:28:08
Django version 1.8.7, using settings ‘esms.settings‘
Starting development server at http://0.0.0.0:8080/
Quit the server with CONTROL-C.
标签:
原文地址:http://www.cnblogs.com/weiok/p/5503883.html