jubo的学習記録

日々自分の技量のなさに悩みながら這いつくばって頑張っているエンジニアが勉強・学習したことの記録です。

Docker学習中に詰まったところ1

オライリーのDockerという本を1周しようとして詰まったところの記録

5章 開発でのDockerの利用(p76)uWSGI を追加するところでエラーが出て詰んだ。

$ cat Dockerfile
FROM python:3.4

RUN pip install Flask==0.10.1 uWSGI==2.0.8




WORKDIR /app
COPY app /app

CMD ["uwsgi", "--http", "0.0.0.0:9090", "--wsgi-file", "/app/identidock.py", "--callable", "app", "--stats", "0.0.0.0:9191"]

本に書かれている内容そのまま入力して、実行するもエラー

$ docker build -t identidock .
Sending build context to Docker daemon  3.584kB
Step 1/5 : FROM python:3.4
 ---> 8c62b065252f
Step 2/5 : RUN pip install Flask==0.10.1 uWSGI==2.0.8
 ---> Running in 69daeb0e688b
DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).
Collecting Flask==0.10.1
  Downloading https://files.pythonhosted.org/packages/db/9c/149ba60c47d107f85fe52564133348458f093dd5e6b57a5b60ab9ac517bb/Flask-0.10.1.tar.gz (544kB)
Collecting uWSGI==2.0.8
  Downloading https://files.pythonhosted.org/packages/4c/3f/7276c97817bd710aada1e3e69f45d6eed11fc625474a34f57799f762d77f/uwsgi-2.0.8.tar.gz (775kB)
Collecting Werkzeug>=0.7 (from Flask==0.10.1)
  Downloading https://files.pythonhosted.org/packages/c2/e4/a859d2fe516f466642fa5c6054fd9646271f9da26b0cac0d2f37fc858c8f/Werkzeug-0.16.1-py2.py3-none-any.whl (327kB)
Collecting Jinja2>=2.4 (from Flask==0.10.1)
  Downloading https://files.pythonhosted.org/packages/65/e0/eb35e762802015cab1ccee04e8a277b03f1d8e53da3ec3106882ec42558b/Jinja2-2.10.3-py2.py3-none-any.whl (125kB)
Collecting itsdangerous>=0.21 (from Flask==0.10.1)
  Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->Flask==0.10.1)
  Downloading https://files.pythonhosted.org/packages/99/c9/5d5dcf2aa90f1d4500e92467a04f63b3708ee6e5764b40b2445e767ab8dc/MarkupSafe-1.1.1-cp34-cp34m-manylinux1_x86_64.whl
Building wheels for collected packages: Flask, uWSGI
  Building wheel for Flask (setup.py): started
  Building wheel for Flask (setup.py): finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/e1/f2/be/1c4f307a41aad7e632f79c0242a2714ecde24b663da3519665
  Building wheel for uWSGI (setup.py): started
  Building wheel for uWSGI (setup.py): finished with status 'error'
  Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-lsst4t2x/uWSGI/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-hzl3idt_ --python-tag cp34:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib
  copying uwsgidecorators.py -> build/lib
  installing to build/bdist.linux-x86_64/wheel
  running install
  using profile: buildconf/default.ini
  detected include path: ['/usr/lib/gcc/x86_64-linux-gnu/6/include', '/usr/local/include', '/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed', '/usr/include/x86_64-linux-gnu', '/usr/include']
  Patching "bin_name" to properly install_scripts dir
  detected CPU cores: 2
  configured CFLAGS: -O2 -I. -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-format -Wno-format-security -DUWSGI_HAS_IFADDRS -DUWSGI_ZLIB -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY  -DUWSGI_PCRE -DUWSGI_ROUTING -DUWSGI_VERSION="\"2.0.8\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="0" -DUWSGI_VERSION_MINOR="8" -DUWSGI_VERSION_REVISION="0" -DUWSGI_VERSION_CUSTOM="\"\"" -DUWSGI_YAML -DUWSGI_SSL -I/usr/include/libxml2 -DUWSGI_XML -DUWSGI_XML_LIBXML2 -DUWSGI_PLUGIN_DIR="\".\"" -DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(ugreen);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);" -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(ugreen);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);"
  *** uWSGI compiling server core ***
  [thread 0][gcc -pthread] core/utils.o
  [thread 1][gcc -pthread] core/protocol.o
  [thread 1][gcc -pthread] core/socket.o
  [thread 1][gcc -pthread] core/logging.o
  [thread 0][gcc -pthread] core/master.o
  [thread 1][gcc -pthread] core/master_utils.o
  [thread 0][gcc -pthread] core/emperor.o
  [thread 1][gcc -pthread] core/notify.o
  [thread 0][gcc -pthread] core/mule.o
  [thread 1][gcc -pthread] core/subscription.o
  [thread 0][gcc -pthread] core/stats.o
  [thread 1][gcc -pthread] core/sendfile.o
  [thread 1][gcc -pthread] core/async.o
  [thread 0][gcc -pthread] core/master_checks.o
  [thread 1][gcc -pthread] core/fifo.o
  [thread 0][gcc -pthread] core/offload.o
  [thread 1][gcc -pthread] core/io.o
  [thread 0][gcc -pthread] core/static.o
  [thread 0][gcc -pthread] core/websockets.o
  [thread 1][gcc -pthread] core/spooler.o
  [thread 0][gcc -pthread] core/snmp.o
  [thread 1][gcc -pthread] core/exceptions.o
  [thread 0][gcc -pthread] core/config.o
  [thread 1][gcc -pthread] core/setup_utils.o
  [thread 1][gcc -pthread] core/clock.o
  [thread 0][gcc -pthread] core/init.o
  [thread 1][gcc -pthread] core/buffer.o
  [thread 0][gcc -pthread] core/reader.o
  [thread 1][gcc -pthread] core/writer.o
  [thread 0][gcc -pthread] core/alarm.o
  [thread 1][gcc -pthread] core/cron.o
  [thread 0][gcc -pthread] core/hooks.o
  [thread 1][gcc -pthread] core/plugins.o
  [thread 0][gcc -pthread] core/lock.o
  [thread 1][gcc -pthread] core/cache.o
  [thread 0][gcc -pthread] core/daemons.o
  [thread 0][gcc -pthread] core/errors.o
  [thread 0][gcc -pthread] core/hash.o
  [thread 1][gcc -pthread] core/master_events.o
  [thread 0][gcc -pthread] core/chunked.o
  [thread 1][gcc -pthread] core/queue.o
  [thread 0][gcc -pthread] core/event.o
  [thread 1][gcc -pthread] core/signal.o
  [thread 0][gcc -pthread] core/strings.o
  [thread 1][gcc -pthread] core/progress.o
  [thread 1][gcc -pthread] core/timebomb.o
  [thread 0][gcc -pthread] core/ini.o
  [thread 1][gcc -pthread] core/fsmon.o
  [thread 0][gcc -pthread] core/mount.o
  [thread 1][gcc -pthread] core/metrics.o
  [thread 0][gcc -pthread] core/plugins_builder.o
  [thread 0][gcc -pthread] core/sharedarea.o
  [thread 1][gcc -pthread] core/rpc.o
  [thread 0][gcc -pthread] core/gateway.o
  [thread 1][gcc -pthread] core/loop.o
  [thread 0][gcc -pthread] core/cookie.o
  [thread 1][gcc -pthread] core/querystring.o
  [thread 0][gcc -pthread] core/rb_timers.o
  [thread 1][gcc -pthread] core/transformations.o
  [thread 0][gcc -pthread] core/uwsgi.o
  [thread 1][gcc -pthread] proto/base.o
  [thread 1][gcc -pthread] proto/uwsgi.o
  [thread 1][gcc -pthread] proto/http.o
  [thread 1][gcc -pthread] proto/fastcgi.o
  [thread 1][gcc -pthread] proto/scgi.o
  [thread 1][gcc -pthread] proto/puwsgi.o
  [thread 0][gcc -pthread] lib/linux_ns.o
  [thread 1][gcc -pthread] core/zlib.o
  [thread 0][gcc -pthread] core/regexp.o
  [thread 1][gcc -pthread] core/routing.o
  [thread 0][gcc -pthread] core/yaml.o
  [thread 0][gcc -pthread] core/ssl.o
  [thread 0][gcc -pthread] core/legion.o
  [thread 1][gcc -pthread] core/xmlconf.o
  [thread 1][gcc -pthread] core/dot_h.o
  [thread 1][gcc -pthread] core/config_py.o
  *** uWSGI compiling embedded plugins ***
  [thread 1][gcc -pthread] plugins/python/python_plugin.o
  [thread 0][gcc -pthread] plugins/python/pyutils.o
  [thread 0][gcc -pthread] plugins/python/pyloader.o
  [thread 1][gcc -pthread] plugins/python/wsgi_handlers.o
  [thread 0][gcc -pthread] plugins/python/wsgi_headers.o
  [thread 1][gcc -pthread] plugins/python/wsgi_subhandler.o
  [thread 0][gcc -pthread] plugins/python/web3_subhandler.o
  [thread 1][gcc -pthread] plugins/python/pump_subhandler.o
  [thread 0][gcc -pthread] plugins/python/gil.o
  [thread 0][gcc -pthread] plugins/python/uwsgi_pymodule.o
  [thread 1][gcc -pthread] plugins/python/profiler.o
  [thread 1][gcc -pthread] plugins/python/symimporter.o
  [thread 1][gcc -pthread] plugins/python/tracebacker.o
  [thread 1][gcc -pthread] plugins/python/raw.o
  [thread 1][gcc -pthread] plugins/gevent/gevent.o
  [thread 0][gcc -pthread] plugins/gevent/hooks.o
  [thread 1][gcc -pthread] plugins/ping/ping_plugin.o
  [thread 0][gcc -pthread] plugins/cache/cache.o
  [thread 1][gcc -pthread] plugins/nagios/nagios.o
  [thread 1][gcc -pthread] plugins/rrdtool/rrdtool.o
  [thread 0][gcc -pthread] plugins/carbon/carbon.o
  [thread 1][gcc -pthread] plugins/rpc/rpc_plugin.o
  [thread 0][gcc -pthread] plugins/corerouter/cr_common.o
  [thread 0][gcc -pthread] plugins/corerouter/cr_map.o
  [thread 1][gcc -pthread] plugins/corerouter/corerouter.o
  plugins/corerouter/cr_map.c: In function ‘uwsgi_cr_map_use_static_nodes’:
  plugins/corerouter/cr_map.c:154:5: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
       if (!next_node)
       ^~
  plugins/corerouter/cr_map.c:157:6: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
        while (tmp_node != next_node) {
        ^~~~~
  cc1: all warnings being treated as errors

  ----------------------------------------
  Failed building wheel for uWSGI
  Running setup.py clean for uWSGI
Successfully built Flask
Failed to build uWSGI
Installing collected packages: Werkzeug, MarkupSafe, Jinja2, itsdangerous, Flask, uWSGI
  Running setup.py install for uWSGI: started
    Running setup.py install for uWSGI: finished with status 'error'
    Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-lsst4t2x/uWSGI/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-bhprc8s3/install-record.txt --single-version-externally-managed --compile:
    running install
    using profile: buildconf/default.ini
    detected include path: ['/usr/lib/gcc/x86_64-linux-gnu/6/include', '/usr/local/include', '/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed', '/usr/include/x86_64-linux-gnu', '/usr/include']
    Patching "bin_name" to properly install_scripts dir
    detected CPU cores: 2
    configured CFLAGS: -O2 -I. -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-format -Wno-format-security -DUWSGI_HAS_IFADDRS -DUWSGI_ZLIB -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY  -DUWSGI_PCRE -DUWSGI_ROUTING -DUWSGI_VERSION="\"2.0.8\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="0" -DUWSGI_VERSION_MINOR="8" -DUWSGI_VERSION_REVISION="0" -DUWSGI_VERSION_CUSTOM="\"\"" -DUWSGI_YAML -DUWSGI_SSL -I/usr/include/libxml2 -DUWSGI_XML -DUWSGI_XML_LIBXML2 -DUWSGI_PLUGIN_DIR="\".\"" -DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(ugreen);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);" -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(ugreen);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);"
    *** uWSGI compiling server core ***
    core/utils.o is up to date
    core/protocol.o is up to date
    core/socket.o is up to date
    core/logging.o is up to date
    core/master.o is up to date
    core/master_utils.o is up to date
    core/emperor.o is up to date
    core/notify.o is up to date
    core/mule.o is up to date
    core/subscription.o is up to date
    core/stats.o is up to date
    core/sendfile.o is up to date
    core/async.o is up to date
    core/master_checks.o is up to date
    core/fifo.o is up to date
    core/offload.o is up to date
    core/io.o is up to date
    core/static.o is up to date
    core/websockets.o is up to date
    core/spooler.o is up to date
    core/snmp.o is up to date
    core/exceptions.o is up to date
    core/config.o is up to date
    core/setup_utils.o is up to date
    core/clock.o is up to date
    core/init.o is up to date
    core/buffer.o is up to date
    core/reader.o is up to date
    core/writer.o is up to date
    core/alarm.o is up to date
    core/cron.o is up to date
    core/hooks.o is up to date
    core/plugins.o is up to date
    core/lock.o is up to date
    core/cache.o is up to date
    core/daemons.o is up to date
    core/errors.o is up to date
    core/hash.o is up to date
    core/master_events.o is up to date
    core/chunked.o is up to date
    core/queue.o is up to date
    core/event.o is up to date
    core/signal.o is up to date
    core/strings.o is up to date
    core/progress.o is up to date
    core/timebomb.o is up to date
    core/ini.o is up to date
    core/fsmon.o is up to date
    core/mount.o is up to date
    core/metrics.o is up to date
    core/plugins_builder.o is up to date
    core/sharedarea.o is up to date
    core/rpc.o is up to date
    core/gateway.o is up to date
    core/loop.o is up to date
    core/cookie.o is up to date
    core/querystring.o is up to date
    core/rb_timers.o is up to date
    core/transformations.o is up to date
    core/uwsgi.o is up to date
    proto/base.o is up to date
    proto/uwsgi.o is up to date
    proto/http.o is up to date
    proto/fastcgi.o is up to date
    proto/scgi.o is up to date
    proto/puwsgi.o is up to date
    lib/linux_ns.o is up to date
    core/zlib.o is up to date
    core/regexp.o is up to date
    core/routing.o is up to date
    core/yaml.o is up to date
    core/ssl.o is up to date
    core/legion.o is up to date
    core/xmlconf.o is up to date
    [thread 1][gcc -pthread] core/dot_h.o
    [thread 0][gcc -pthread] core/config_py.o
    plugins/python/python_plugin.o is up to date
    plugins/python/pyutils.o is up to date
    plugins/python/pyloader.o is up to date
    plugins/python/wsgi_handlers.o is up to date
    plugins/python/wsgi_headers.o is up to date
    plugins/python/wsgi_subhandler.o is up to date
    plugins/python/web3_subhandler.o is up to date
    plugins/python/pump_subhandler.o is up to date
    plugins/python/gil.o is up to date
    plugins/python/uwsgi_pymodule.o is up to date
    plugins/python/profiler.o is up to date
    plugins/python/symimporter.o is up to date
    plugins/python/tracebacker.o is up to date
    plugins/python/raw.o is up to date
    plugins/gevent/gevent.o is up to date
    plugins/gevent/hooks.o is up to date
    plugins/ping/ping_plugin.o is up to date
    plugins/cache/cache.o is up to date
    plugins/nagios/nagios.o is up to date
    plugins/rrdtool/rrdtool.o is up to date
    plugins/carbon/carbon.o is up to date
    plugins/rpc/rpc_plugin.o is up to date
    plugins/corerouter/cr_common.o is up to date
    plugins/corerouter/corerouter.o is up to date
    *** uWSGI compiling embedded plugins ***
    [thread 1][gcc -pthread] plugins/corerouter/cr_map.o
    [thread 0][gcc -pthread] plugins/fastrouter/fastrouter.o
    plugins/corerouter/cr_map.c: In function ‘uwsgi_cr_map_use_static_nodes’:
    plugins/corerouter/cr_map.c:154:5: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
         if (!next_node)
         ^~
    plugins/corerouter/cr_map.c:157:6: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
          while (tmp_node != next_node) {
          ^~~~~
    cc1: all warnings being treated as errors

    ----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-lsst4t2x/uWSGI/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-bhprc8s3/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-lsst4t2x/uWSGI/
You are using pip version 19.0.3, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip install Flask==0.10.1 uWSGI==2.0.8' returned a non-zero code: 1

どうやら、uWSGI バージョン2.0.8 ではビルド中にエラーを引き起こす模様。
そのため、バージョンを2.0.15に上げて対応します。
また、python3.4について DEPRECATION が表示されているのですが、python3.5にしたらそれも解消できます。
ついでに、エラー文中にpipのバージョンについても書かれていたので上げた結果が下記になります。

$ cat Dockerfile
FROM python:3.5

RUN pip install --upgrade pip
RUN pip install Flask==0.10.1
RUN pip install uWSGI==2.0.15
WORKDIR /app
COPY app /app

CMD ["uwsgi", "--http", "0.0.0.0:9090", "--wsgi-file", "/app/identidock.py", "--callable", "app", "--stats", "0.0.0.0:9191"]