Boot2docker, docker, django on mac os x

I want to run a Django application in docker on Mac OS X. I installed docker using the get-started tutorial.

I refer to the Django document in the docker library for creating the image, https://github.com/docker-library/docs/tree/master/django , I add the Dockerfile to the new folder of the Django project

The problem is that I am creating an image and successfully starting the container, but whenever I visit container-ip:8000 or http://localhost:8000 , it does not work. Does anyone have any solutions?

Here are the images and container information; docker_test is my application

 REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE docker_test latest fd6ceebc0c58 13 hours ago 761.5 MB django onbuild 9cbcfd71d759 30 hours ago 728.6 MB CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cbf98a73ea0a docker_test "python manage.py ru 26 minutes ago Up 26 minutes 0.0.0.0:8000->8000/tcp docker_app 
+3
python django docker boot2docker macos
Jul 11 '15 at 3:34
source share
1 answer

whenever I visit container-ip: 8000 or http: // localhost: 8000 , it does not work

See docker / issues / 4007 : you will need to use port forwarding when using boot2docker on OSX.
This means that the VM boot loader must redirect port 8000 to the actual OSX host.
I mentioned it here :

 $ VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port8000,tcp,,8000,,8000"; 

If vm is already running, you should run this other command:

 $ VBoxManage controlvm "boot2docker-vm" natpf1 "tcp-port8000,tcp,,8000,,8000"; 

This may help, for example, a script .

As shown in the Boot2docker section on OsX ", localhost does not work:

The reason it doesn't work is because your DOCKER_HOST address DOCKER_HOST not the localhost address ( 0.0.0.0 ), but the address of the boot2docker virtual machine.

Get the address of the boot2docker virtual machine.

 $ boot2docker ip 192.168.59.103 

Enter http://192.168.59.103:8000 in your browser.

+6
Jul 11 '15 at 4:17
source share



All Articles