If I run the following code, I can convert the csv file into a format that I require.
import csv import json csvfile = open('/tmp/head.csv', 'r') jsonfile = open('/tmp/file.json', 'w') fieldnames = ("user","messageid","destination","col1", "col2", "code1","code2", "mydate", "status") reader = csv.DictReader( csvfile, fieldnames) for row in reader: jsonfile.write(json.dumps(row))
When I run the code at command prompt, it works.
But if I create docker container, ubuntu refused to write to the disk.
alias python34='docker run -i -v "$(pwd)":/tmp/ --rm shantanuo/pyrun:3.4 python "$@"' python34 /tmp/convert.py
I got segmentation fault error. I tried disabling ubuntu firewall using
sudo ufw disable
I tried removing apparmour. But I am still not able to write to /tmp/ folder of host machine through python container.
This is ubuntu specific issue. I am able to use the same alias on Amazon Linux ec2 instance.