Adding a data file to a Dockerfile

I would like to use a small CSV as an example dataset.

My Dockerfile is as follows (same as the example Dockerfile except I COPY the file into the container and I pip install polars.

FROM ubuntu:focal

# Installing different modules
COPY data /usercode
RUN	apt update && apt install -y software-properties-common &&\
	add-apt-repository ppa:deadsnakes/ppa &&\
	apt-get -y install curl &&\
	apt install -y python3.8 &&\
	apt-get install -y python3-distutils python3-apt &&\
	curl -o && python3 &&\
	pip3 install pandas plotly polars matplotlib

I’ve set usercode as the target directory because I can see that’s the directory the code widget runs in. I’m not sure if this is correct.

I then create a tarball that includes the data directory where the file is

tar -czvf docker-edu.tar.gz Dockerfile data

I upload this and the image builds.

In the code widget I can see I’m in the usercode directory but the available files are:
‘__ed_mem.txt’,’ __ed_stdout.txt’,’,’__ed_stderr.txt’, ‘’,‘output’

Is it possible for my to upload a CSV file and access it in this way in python?
Thanks for any help

Course: Create Courses Using Educative's Publishing Platform - Free Interactive Course
Lesson: Profile Page Settings - Create Courses Using Educative's Publishing Platform

Hi @Liam_Brannigan,

Thank you so much for reaching out to us.

You can try to use COPY . . instead and in your docker job, you can copy the file (using cp data.csv usercode/) into the user code directory. Also, please remember that you can’t see that in your code widget but it will work.

If there will be any issue then please do let me know. Thanks.