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.
- Django : Deduce duplicate key exception from IntegrityError
- Django and reverse relations from foreign keys
- Do RESTful service parameters have to be discoverable?
- Python error AttributeError: 'str' object has no attribute 'setdefault'
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.
- Django Apache Redirect Problem
- Django – How to prevent database foreign key constraint creation
- Python/Django: Why does importing a module right before using it prevent a circular import?
- How to truncate html without breaking the tags?
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