Merge pull request #6725 from 2tunnels/patch-1

update compose django example
This commit is contained in:
Maria Bermudez 2019-01-15 16:57:40 -08:00 committed by GitHub
commit 565537843b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -30,9 +30,9 @@ and a `docker-compose.yml` file. (You can use either a `.yml` or `.yaml` extensi
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
COPY requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
COPY . /code/
This `Dockerfile` starts with a [Python 3 parent image](https://hub.docker.com/r/library/python/tags/3/).
The parent image is modified by adding a new `code` directory. The parent image is further modified
@ -46,8 +46,8 @@ and a `docker-compose.yml` file. (You can use either a `.yml` or `.yaml` extensi
6. Add the required software in the file.
Django>=1.8,<2.0
psycopg2
Django>=2.0,<3.0
psycopg2>=2.7,<3.0
7. Save and close the `requirements.txt` file.
@ -71,7 +71,7 @@ and a `docker-compose.yml` file. (You can use either a `.yml` or `.yaml` extensi
image: postgres
web:
build: .
command: python3 manage.py runserver 0.0.0.0:8000
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
@ -93,15 +93,15 @@ In this step, you create a Django starter project by building the image from the
2. Create the Django project by running
the [docker-compose run](/compose/reference/run/) command as follows.
sudo docker-compose run web django-admin.py startproject composeexample .
sudo docker-compose run web django-admin startproject composeexample .
This instructs Compose to run `django-admin.py startproject composeexample`
This instructs Compose to run `django-admin startproject composeexample`
in a container, using the `web` service's image and configuration. Because
the `web` image doesn't exist yet, Compose builds it from the current
directory, as specified by the `build: .` line in `docker-compose.yml`.
Once the `web` service image is built, Compose runs it and executes the
`django-admin.py startproject` command in the container. This command
`django-admin startproject` command in the container. This command
instructs Django to create a set of files and directories representing a
Django project.
@ -202,7 +202,7 @@ In this section, you set up the database connection for Django.
5. List running containers.
In another terminal window, list the running Docker processes with the `docker ps` command.
In another terminal window, list the running Docker processes with the `docker container ls` command.
```none
$ docker ps

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 18 KiB