Docker setup the development environment
There is a Python2 project, dependent RabbitMQ, Redis, MySQL
RabbitMQ installation cumbersome, and their own need to install other dependencies
of the project itself also uses several graphics libraries, dependencies under different development environments (Win, Mac, Linux) is differences in
my development environment is Windows, to build such an environment is very troublesome, if Docker will be a lot easier.
Docker MySQL
Get a mirror
docker pull mysql:5.6
Start container, 123456, map port 3306
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
Into the container, create a remote access user
docker exec -it <容器> /bin/bash
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
Docker Redis
Mirror Pull
docker pull redis:5.0
Starting container port mapping 6379
docker run -p 6379:6379 -d --name redis-5.0 redis:5.0
Docker RabbitMQ
Mirror Pull
docker pull rabbitmq
Starting container port is automatically mapped
hostname is the host name of the container
docker run -d --hostname my-rabbit --name rabbitmq rabbitmq:latest
Into the container, you can view the status RabbitMQ
docker exec -it <容器> /bin/bash
rabbitmqctl status
Docker Python2.7
The various dependencies have been installed, the operating environment is now built Python
pulling mirroring
docker pull python:2.7
Start container
-p 8000: 8000 mapped port is access port projects
-v ~ / workspace: / root / workspace to workspace directory in the home directory is mapped to / root / workspace directory, this directory is the code
--privileged = true resolve within docker catalog no access problem
--link mysql: mysqldb three link parameters, for example to mysql, mysql meant to create a mapping of host names to mysqldb, that is to say by ping mysqldb, access mysql container
docker run -itd -p 8000:8000 -v ~/workspace:/root/workspace --privileged=true --link mysql:mysqldb --link redis-5.0:redisdb --link rabbitmq:rabbitmq --name dev_docker python:2.7
It should be noted, this is a django project, following the start-up mode can only be accessed inside docker
because the default listener is localhost, only monitors the machine request
python manage.py runserver 8000
The following command can be visited on the outside
python manage.py runserver 0.0.0.0:8000