Closed dal233 closed 3 years ago
If you build the image correctly from the instruction in step 3:
$ docker build --pull --tag python/ch6 .
python/ch6
is the name of the image you will run as a container in the later steps:
$ docker run --rm --network=host -v "$(PWD):/usr/src/app" \
--name python python/ch6 bin/weather.py \
--output data/wx.txt \
--stations KSFO,KDEN,KSTL,KJFK
$ docker run --rm --network=host -v "$(PWD):/usr/src/app" \
--name python python/ch6 bin/weather.py \
--input data/wx.txt \
--db weatherdb
You can also use the Makefile:
$ make up
$ make build-python
$ make dump-weather
$ make load-weather
Additionally, the book was written to use InfluxDB 1.X, and since the access policies for InfluxDB 2.X are stricter, you will get the following message if you try to pull and run an InfluxDB 2:
INFO:root:http://localhost:8086/query?q=CREATE+DATABASE+weatherdb
ERROR:root:create_database: 401:Unauthorized
Traceback (most recent call last):
File "/usr/src/app/bin/weather.py", line 164, in <module>
sys.exit(main())
File "/usr/src/app/bin/weather.py", line 159, in main
load_wx_data(db_host=args.host, db_port=args.port, db_name=args.database, input_file=args.input_file)
File "/usr/src/app/bin/weather.py", line 80, in load_wx_data
create_database(db_host=db_host, db_port=db_port, db_name=db_name)
File "/usr/src/app/bin/weather.py", line 19, in create_database
raise Exception(f'create_database: {response.status_code}:{response.reason}')
Exception: create_database: 401:Unauthorized
You can lock to the InfluxDB 1.X by creating a .env
file with the following contents:
INFL_TAG=1.8
or you can pull the latest InfluxDB (2.X), but you will then need to follow their installation instructions in order to create databases via the API.
I ran this command from the text:
docker run --rm --network=host -v "$(PWD):/usr/src/app" --name python python/Chapter06 bin/weather.py --output data/wx.txt --stations KSFO,KDEN,KSTL,KJFK
And get this error:
docker: invalid reference format: repository name must be lowercase.
Any thoughts on what is going on are appreciated.