[Solved]-No django app created when following the docker-compose tutorial

2πŸ‘

βœ…

You need to set up a dockerfile so that when you do a docker build, it copies your local code onto the container. To get started, you will need to copy the files from container to local. Look here for that. Or just overwrite the directory with your own django app

Copying files from host to Docker container

example:

FROM python:2.7
RUN mkdir /code
WORKDIR /code
ADD . /code/

0πŸ‘

ADD . /code/ in docker file will be actually mount your local working directory inside the docker image.
So you can make changes to code inside your working directory and same will be updated inside the docker container as working directory is mounted inside the same.

Use dockerfile as shown in tutorial to generate the image and use the same image for creating container.

0πŸ‘

Had the same issue, and that is because I changed the folder name β€œ/code” in Dockerfile, but forget to change folder name in docker-compose.yum file.
So be sure the folder name in the 2 files are the same.

And actually the container(and all the files) is already created in /var/lib/docker/overlay2/…/diff/code/, that is why the log mentioned about β€œSuccessfully built …”, but not copied back to the folder where you trigger the cmd.
Hope this helps.

πŸ‘€zhihong

0πŸ‘

I just had this issue on docker with WSL and tracked it down – it was an issue with volume mounting. Basically to solve this you need to create your project directory in WSL on the mounted c volume on not in a "native" WSL directory. In my case this meant creating my project directory here: /c/Users/seth/proj_dir

You can read more about mounting issues in this excellent WSL/Docker tutorial (search for "Create and modify the new WSL configuration file" and then search again for "docker-compose up": https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly

πŸ‘€seth

Leave a comment