I started to use Docker for different purposes, ranging from development to uses where a virtual machine is overkill.
Lately, I have played around with Python 3 and Django and decided to create a Docker environment where I can run the Django stuff while having the flexibility to change library versions as I need to.
You can download all the files used in this post on GitHub.
The repository had major changes, so this article got updated accordingly. (8. August 2016)
I started with the following Dockerfile:
From python:3.4.3 MAINTAINER Davide Bove <info@davidebove.com> ENV PYTHONUNBUFFERED 1 RUN pip install django && mkdir /static COPY django_bash_completion /etc/bash_completion.d/django_bash_completion WORKDIR /code CMD ["/bin/bash", "--init-file", "/etc/bash_completion.d/django_bash_completion"]
This simple container installs Django and adds bash completion for it.
If you want to run the container, you can run the given shell script with sh run_docker.sh
. The script starts an interactive bash session, which offers all the python and Django tools you usually need.
When the built-in server is started, the app can be accessed on your machine with the following url: http://localhost:8000/.
Now you can start developing on your local machine, and all changes are loaded automatically into the Django runtime. You can also always quit the server manually and restart the docker container.
Note: The GitHub repository also contains a docker-compose file, which is another method to run docker containers. The Docker Compose method will be shown in another post.
The Docker-Compose method was removed, as the additional database container is not used anymore.
As a Newbie, I am always exploring online for articles that can aid me. Thank you
Some truly great info , Gladiolus I discovered this.
Appreciate the recommendation. Let me try it out.
I am really impressed with your writing skills and also with the layout on your weblog. Is this a paid theme or did you customize it yourself? Either way keep up the excellent quality writing, it is rare to see a great blog like this one today..
I think this is one of the most significant information for me.
And i’m glad reading your article. But wanna remark on few general things, The site style is perfect, the articles is really excellent : D.
Good job, cheers
I could not refrain from commenting. Very well
written!
Hello! Do you know if they make any plugins
to assist with Search Engine Optimization? I’m trying to
get my blog to rank for some targeted keywords but I’m not
seeing very good gains. If you know of any please share.
Cheers!
Wow, these spam comments are really random…
Hello there, You’ve done a fantastic job. I’ll definitely digg it and personally suggest to my friends.
I am confident they will be benefited from this website.
You can definitely see your enthusiasm within the
work you write. The sector hopes for more passionate writers such
as you who aren’t afraid to mention how they believe.
All the time go after your heart.
I couldn’t resist commenting. Exceptionally well written!