Getting "Error processing tar file(exit status 1): open /myenv/include/python3.6m/Python-ast.h: no such file or directory" while docker-compose build

Issue

So I am pretty new to docker and django. Unfortunately while running the below command on my linux machine which i am connected using my physical windows machine using putty:

docker-compose build

I am getting an error:

Error processing tar file(exit status 1): open /myenv/include/python3.6m/Python-ast.h: no such file or directory

‘myenv’ is the environment I have created inside my folder.

I am getting a container started on port 9000. The app doesn’t have anything yet just a simple project so i just expect to see the ‘congratulations’ screen. I don’t know where I am going wrong. My final goal would be to run the docker url in my windows browser and see the screen of docker container.

This is my docker-compose.yml file:

version: '3'

services:
     web:
        build: .
        command: python manage.py runserver 0.0.0.0:9000
        ports:
            - 202.179.92.106:8000:9000

the IP: 202.179.92.106 is my public IP. I did the above binding so as to access the docker container from my windows machine. Would request additional inputs for the port binding as well if correct/incorrect.

Below is my Dockerfile:

FROM python:3.6.9

RUN mkdir djangotest

WORKDIR djangotest

ADD . /djangotest

RUN pip install -r requirements.txt

Please help me out peeps!

Solution

If you have a virtual environment in your normal development tree, you can’t copy it into a Docker image. You can exclude this from the build sequence by mentioning it in a .dockerignore file:

# .dockerignore
myenv

Within the Dockerfile, the RUN pip install line will install your application’s dependencies into the Docker image, so you should have a complete self-contained image.

Answered By – David Maze

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published