Docker Community Forums

Share and learn in the Docker community.

Docker container doesn't starts after changing host directory

I have a django app which i’m dockerizing. Below is the docker-compose.yml file (Only django part is given here)

    build: .
    command: python ./webapp/
    restart: always
      - .:/code
      - ./webapp/static:/static
      - nginx_network
      - couchserver_network
      - dummyapi_flaskapp_network

when i change the name of the host directory from where it is run, i’m getting the following error : python: can't open file './webapp/': [Errno 2] No such file or directory
I have copied the host directory to image using :

RUN mkdir /code
COPY . /code/

So after renaming my host directory why python is unable to find the file as it is available in containers code directory.

I’m novice in docker and have little or no knowledge in volumes. Any help is really appreciated

Looking at the docker-compose.yml you’ve linked to, I don’t see any volume entry. Without that, there’s no connection possible between the files on your host and the files inside the container. You’ll need a docker-compose.yml that includes a volume entry, like:

version: ‘2’


context: .
dockerfile: ./.docker/angular-seed.development.dockerfile
command: npm start
container_name: angular-seed-start
image: angular-seed
- dev-network
- ‘5555:5555’
- .:/home/app/angular-seed

driver: bridge
Docker-machine runs docker inside of a virtual box VM. By default, I believe c:\Users is shared into the VM, but you’ll need to check the virtual box settings to confirm this. Any host directories you try to map into the container are mapped from the VM, so if your folder is not shared into that VM, your files won’t be included.

With the IP, localhost works on Linux hosts and newer versions of docker for windows/mac. Older docker-machine based installs need to use the IP of the virtual box VM.