Reputation: 3469
I'm trying to run a simple python script that takes a json string as an argument in a docker container. However I get the following error:
Traceback (most recent call last):
File "/root/simple.py", line 2, in <module>
import json
ImportError: No module named json
I'm running the standard ubuntu:12.04 image. Here's how I call up the container:
docker run -v $(pwd)/:/root/ ubuntu:12.04 python /root/simple.py '[{"hi":"bye"}]'
My simple.py
script is just:
import sys
import json
configs = json.loads(sys.argv[1])
print configs
def read_option_keys(json_file):
json_file[0]["new"] = None
print json.dumps(json_file)
read_option_keys(configs)
Any idea why it's not returning the following as expected:
[{u'hi': u'bye'}]
[{"hi": "bye", "new": null}]
Upvotes: 0
Views: 1322
Reputation: 1
Docker is a containerized instance, so your python script has no knowledge of the outside world. You are currently running the Ubuntu image, but it doesn't contain the python standard module. You should run a python image instead or add python to your Ubuntu image
Upvotes: 0
Reputation: 3469
I was able to solve the issue myself. Ubuntu image is super bare-bones. I pulled the dockerfile/python
image and now it works.
Upvotes: 1